本文转自:http://jophy.iteye.com/blog/337321
当月数据
select * from table t
where t.create_time >=TRUNC(SYSDATE, 'MM')
and t.create_time<=last_day(SYSDATE)
create_time为你要查询的时间
当年数据
select * from table t
where t.create_time >=trunc(sysdate,'YYYY')
and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1
本周(国外周日为一个星期第一天)
where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6
本周(国内周一为一个星期第一天)
where t.create_time >=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7)+1
本文介绍了如何使用SQL查询语句根据不同的时间范围(月、年、周)从数据库中获取数据的方法,包括创建时间在当前月份、当前年份、当前一周的数据查询。
739

被折叠的 条评论
为什么被折叠?



