2011-09-14 3 views
3

시간 소인이 과거 5 분 사이 인 행을 선택해야합니다. 어떻게해야합니까? 다음과 같은 것 :SYSDATE의 시간 대괄호

select * from tableName where timestamp between sysdate and up to -5 min 

더 간단합니다.

답변

8
select * 
    from tableName 
where timestamp between sysdate and sysdate - interval '5' minute 

또는 이전 스타일 :

select * 
    from tableName 
where timestamp between sysdate and sysdate - 5 * 60/86400 
0
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') NOW 
,   to_char(sysdate - 1/24/12,'yyyy-mm-dd hh24:mi:ss') "5 min. before" 
    from dual; 

NOW     5 min. before 
------------------- ------------------- 
2011-09-15 15:11:06 2011-09-15 15:06:06