oracle 的sql语句查询最近或指定2个小时的数据方式

wattor 2009-09-16 02:28:21
select count(*) from tablename where create_time<to_date('2009-09-16 14:00:00','yyyy-mm-dd hh24:mi:ss') and create_time>to_date('2009-08-16 14:00:00','yyyy-mm-dd hh24:mi:ss')

这个一个查询固定时间的语句,但我想使用方便一点

是否有这样的语句:
1 查询当前时间和当前时间两个小时前这个时间段的sql
也就是说,假设当前时间是xx,
我想查询 xx-2小时 至 xx 这段时间的sql语句?
...全文
885 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liusong_china 2009-09-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 shiyiwan 的回复:]
select count(*) from tablename where create_time between sysdate - 1/12 and sysdate;
[/Quote]
对的
bingwang08 2009-09-17
  • 打赏
  • 举报
回复
支持一下楼上的,简单明了!
shiyiwan 2009-09-16
  • 打赏
  • 举报
回复
select count(*) from tablename where create_time between sysdate - 1/12 and sysdate;

17,090

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧