JAVA—咖啡馆

——欢迎访问rogerfan的博客,常来《JAVA——咖啡馆》坐坐,喝杯浓香的咖啡,彼此探讨一下JAVA技术,交流工作经验,分享JAVA带来的快乐!本网站部分转载文章,如果有版权问题请与我联系。

BlogJava 首页 新随笔 联系 聚合 管理
  447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks

当月数据

Sql代码
  1. select * from table t   
  2. where t.create_time >=TRUNC(SYSDATE, 'MM')   
  3. and t.create_time<=last_day(SYSDATE)  
select * from table t
where t.create_time >=TRUNC(SYSDATE, 'MM')
and t.create_time<=last_day(SYSDATE)


当年数据

Sql代码
  1. select * from table t   
  2. where t.create_time >=trunc(sysdate,'YYYY')   
  3. and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1  
select * from table t
where t.create_time >=trunc(sysdate,'YYYY')
and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1


本周(国外周日为一个星期第一天)

Sql代码
  1. where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6   
where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6


本周(国内周一为一个星期第一天)

Sql代码
  1. where t.create_time >=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7)+1  

posted on 2010-07-13 10:23 rogerfan 阅读(420) 评论(0)  编辑  收藏 所属分类: 【数据库】

只有注册用户登录后才能发表评论。


网站导航: