我想从两小时前和currentime_stamp
之间从Oracle数据库中获取数据。我怎么能这样做?
select count(*) as "trn<5",ROUND(avg (RESPONSE_TIME),2) as avr,ssn
from db_activity a
where a.REQ_TIMESTAMP BETWEEN current_timestamp -2 AND current_timestamp
group by ssn
答案 0 :(得分:1)
使用TIMESTAMP
时,最好使用INTERVAL
:
select count(*) as "trn<5",ROUND(avg (RESPONSE_TIME),2) as avr,ssn
from db_activity a
where a.REQ_TIMESTAMP BETWEEN current_timestamp - INTERVAL '2' HOUR AND current_timestamp
group by ssn
答案 1 :(得分:0)
...where a.REQ_TIMESTAMP >= (SYSDATE-1/12)