当前位置: 代码迷 >> Oracle管理 >> 问个时间查询有关问题
  详细解决方案

问个时间查询有关问题

热度:212   发布时间:2016-04-24 06:20:37.0
问个时间查询问题
怎么查某表一次性从2011-10-15号到2011-11-04号的08:30到09:00的全部记录
这样写只能查出这一天的,怎么才能一次性查出呢 ??
SQL code
select distinct a.test, a.test2, a.test3, a.test4,a.time  from testtime a where a.test1 in ('11', '22')   and a.time between to_date('2011-10-15 08:30', 'YYYY-mm-dd hh24:mi') and       to_date('2011-10-15 09:00', 'YYYY-mm-dd hh24:mi')


------解决方案--------------------
SQL code
select distinct a.test, a.test2, a.test3, a.test4,a.time  from testtime a where a.test1 in ('11', '22')   and a.time >= to_date('2011-10-15 00:00', 'YYYY-mm-dd hh24:mi')    and a.time < to_date('2011-11-05 00:00', 'YYYY-mm-dd hh24:mi')   and to_char(a.time,'hh24:mi') between '08:30' and '09:00' ;
  相关解决方案