2012-09-11 11 views
9

नीचे एक प्रश्न है जो मैं पिछले एक घंटे में अपडेट प्राप्त करने के लिए चल रहा हूं।ओरेकल पिछले एक घंटे में अपडेट किए गए रिकॉर्ड प्राप्त करें

select count(*) 
from my_table 
where last_updated_date between to_date(to_char(sysdate,'YYYY-MM-DD HH24'))-1/24 and to_date(to_char(sysdate,'YYYY-MM-DD HH24')); 

हमारे डीबी देववाणी है और यह

ORA-01861: literal does not match format string 
01861. 00000 - "literal does not match format string" 
*Cause: Literals in the input must be the same length as literals in 
      the format string (with the exception of leading whitespace). If the 
      "FX" modifier has been toggled on, the literal must match exactly, 
      with no extra whitespace. 
*Action: Correct the format string to match the literal. 

इस विफलता का कारण क्या है के साथ विफल हो रहा है?

उत्तर

26

सिर्फ sysdate से 1/24 घटाएँ 1 घंटे पहले

select count(*) from my_table where last_updated_date >= (sysdate-1/24) 
के समय प्राप्त करने के लिए