解决方案 »
- 有没有人啊?这个问题我都问两天了,有没有人能回答啊?
- 请教分段提交的写法!
- oracle union 和 OR 的效率问题 不解
- 请问关于ORACLE中创建TYPE的用法,比如CREATE OR REPLACE TYPE type_str_split IS TABLE OF VARCHAR2 (4000)
- 我的SQL语句出现很奇怪的问题!请您帮忙解答!
- 请高手帮忙,不会写啊
- oracle <>符号和!=符号的区别?
- 如何用sql语句查看Oracle当前的所有会话
- (100)请问Oracle的过程或触发器中能否调用Dos命令,我记得Sql server 可以完成,如果可以如何完成
- 请问,如何某一列的数据不可见?急!
- Oracle时间问题
- 求一条查询语句
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;
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')
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' ;
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-04 00:00', 'YYYY-mm-dd hh24:mi')
and a.time < to_date('2011-11-16 00:00', 'YYYY-mm-dd hh24:mi')
and to_char(a.time,'hh24:mi') between '08:30' and '09:00' ;
或者从数据库中查询出某些天的记录,然后在编程语言中对小时分进行字符串解析
来确定是否为符合条件的记录。
你确定在这个时间区间内会有数据??
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')
FROM testtime a
WHERE a.test1 in ('11', '22')
AND (a.time BETWEEN TO_DATE('2011-10-15 00:00', 'YYYY-mm-dd hh24:mi')
AND 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' ;