我需要从Oracle表中获取数据,其中有一个称为lastupdatedDate
的日期字段,并且我只想获取那些lastupdatedDate
在sysdate
的最后10分钟内的行。
例如,如果我的表中lastupdateDate
是05/20/09 4:20:44
,那么如果我在05/20/09 4:20:44
到05/20/09 4:30:44
之间运行查询,则希望在结果中返回此行,而在05/20/09 5:31:44
时运行查询则不返回此行。
或稍微更易读:
select *
from mytable
where lastupdatedDate > sysdate - interval '10' minute
select *
from mytable
where lastupdatedDate > sysdate - interval '10' minute
select sysdate - 10/(24*60) from dual;
参考上面的示例获取当前时间减去十分钟,然后将其添加到您的查询中。