在Oracle中,我想查系统时间一天的数据,使用这个语句
select * from tablename
where create_time>SYSDATE-1
and create_time<SYSDATE
我想查昨天00:00到今天00:00的sql怎么写,
或者我想查前天08:00到今天08:00的sql怎么写,当然不能写具体时间,因为每次我都查这种数据
select * from tablename
where create_time>SYSDATE-1
and create_time<SYSDATE
我想查昨天00:00到今天00:00的sql怎么写,
或者我想查前天08:00到今天08:00的sql怎么写,当然不能写具体时间,因为每次我都查这种数据
解决方案 »
- sal server2005连接不上
- 急啊!一对多问题!
- oracle游标如何改写成sqlserver游标写法?
- TOAD for Oracle 9.5 安装问题
- oracle10g的FORM中如何通过代码获取该FORM引用网页地址中传进来的参数
- 我使用JAVA JDBC的批量提交插入数据遇到异常(一条违反约束的信息),其后的插入无法进行
- 如何在安装程序中,实现修改系统的环境变量为oracle客户端的安装目录????
- 安装Oracle817后,windows2000的FTP不能用了,如何解决?
- 如何加入数据库的约束(二)??
- 求教:取一行连续相邻5以上不为空的字段的数
- 两个结构一样的表,查询其中一个表没有的数据select语句怎么写
- 海量数据库更新慢怎么处理
where create_time>= trunc(SYSDATE-1)
and create_time <trunc(SYSDATE )
where create_time> trunc(SYSDATE-1)+ 8/24
and create_time < trunc(SYSDATE) + 8/24
where create_time>to_date('20090103 00:00:00','yyyymmdd hh24:mi:ss')
and create_time <to_date(20090104 00:00:00','yyyymmdd hh24:mi:ss')想定时查询出数据,做日志备份或做其他处理,那就写个job
定时运行
where create_time>= trunc(SYSDATE-1)
and create_time <trunc(SYSDATE )select * from tablename
where create_time> trunc(SYSDATE-1)+ 8/24
and create_time < trunc(SYSDATE) + 8/24
顶!
再进一步,我要查一周的数据、一个月的数据怎么做?
一周是固定的
select * from tablename
where create_time> trunc(SYSDATE-7)+ 8/24
and create_time < trunc(SYSDATE) + 8/24
那一个月的数据怎么查?
比如我查上个月8号到这个月8号的数据?
create_time < to_date(to_char(sysdate,'yyyy') || to_char(sysdate,'mm')
|| '08' || '000000','yyyy-mm-dd');
注:时间范围[2009-10-08 00:00:00--2009-11-07 23:59:59]
where create_time
between add_months(to_date(to_char(sysdate,'yyyymm')||'08','yyyymmdd'),-1)
and to_date(to_char(sysdate,'yyyymm')||'08','yyyymmdd');