问个时间查询问题
时间:2011-11-07
来源:互联网
怎么查某表一次性从2011-10-15号到2011-11-04号的08:30到09:00的全部记录
这样写只能查出这一天的,怎么才能一次性查出呢 ??
SQL code
这样写只能查出这一天的,怎么才能一次性查出呢 ??
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')
作者: mirsvip 发布时间: 2011-11-07
多写几个or 试试
作者: psufnxk2000 发布时间: 2011-11-07
select distinct a.test, a.test2, a.test3, a.test4,a.time
from testtime a,
(select to_date('20111015083000', 'yyyymmddhh24miss')+rownum-1 as begintime,
to_date('20111015090000', 'yyyymmddhh24miss')+rownum-1 as endtime
from dual
connect by rownum<=to_date('20111104', 'yyyymmdd')-to_date('20111015', 'yyyymmdd')
)b
where a.test1 in ('11', '22')
and a.time between b.begintime and b.endtime;
from testtime a,
(select to_date('20111015083000', 'yyyymmddhh24miss')+rownum-1 as begintime,
to_date('20111015090000', 'yyyymmddhh24miss')+rownum-1 as endtime
from dual
connect by rownum<=to_date('20111104', 'yyyymmdd')-to_date('20111015', 'yyyymmdd')
)b
where a.test1 in ('11', '22')
and a.time between b.begintime and b.endtime;
作者: yixilan 发布时间: 2011-11-07
SQL code
where trunc(a.time,'dd') between to_date('2011-10-15', 'YYYY-mm-dd') and to_date('2011-11-04', 'YYYY-mm-dd') and a.time-trunc(a.time,'dd') between to_date('2011-10-15 08:30', 'YYYY-mm-dd hh24:mi')-to_date('2011-10-15', 'YYYY-mm-dd') and to_date('2011-10-15 09:00', 'YYYY-mm-dd hh24:mi')-to_date('2011-10-15', 'YYYY-mm-dd')
作者: funfenffun 发布时间: 2011-11-07
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' ;
作者: xiaobn_cn 发布时间: 2011-11-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28