2013-02-25 47 views
1

我的示例表看起來像這樣內更新記錄..查詢來獲取其過去60個mintues

Primary_Key || Start_Time || End_Time || Value 

1 || 24-FEB-13 18:00:00 || 24-FEB-13 19:00:00 || 6 

這些列的數據類型是

Primary_Key -- Int 
Start_Time --- TimeStamp 
End_Time --- TimeStamp 
Value  --- Int 

現在,我想所有的取表中End_Time值在當前時間60分鐘內的記錄?

回答

0

這應該工作:

select * 
from sample s 
where CURRENT_TIMESTAMP - end_time <= 1/24.0 and CURRENT_TIMESTAMP >= end_time 
+0

這個錯誤被扔了ORA-00932:不一致的數據類型:預期INTERVAL DAY TO SECOND了NUMBER – Mahiz 2013-02-25 19:56:44

0

試試這個

select * from yourtable 
WHERE (sysdate - End_Time) * 1440 between 0 and 60 
1

嘗試......

SELECT * FROM yourTable 
WHERE end_time >= CURRENT_TIMESTAMP - NUMToDSInterval(1, 'HOUR') 

,應與DATE和TIMESTAMP和TIMESTAMP WITH工作TIME ZONE值。

0

你可以試試這個 - your_start_date之間選擇你的數據和your_start_date +間隔 '60' MINUTE:

SELECT SYSDATE start_dt, (SYSDATE + INTERVAL '60' MINUTE) end_dt 
    FROM dual 
/

SELECT * FROM 
(
SELECT to_date('24-FEB-13 18:00:00', 'DD-MON-YYYY HH24:MI:SS') your_start_date 
     ,(to_date('24-FEB-13 18:00:00', 'DD-MON-YYYY HH24:MI:SS') + INTERVAL '60' MINUTE) your_end_dt 
FROM dual 
) 
/