当月 当年sql

时间:2022-03-02 08:38:40

本文转自:http://jophy.javaeye.com/blog/337321

当月数据

Java代码
  1. select * from table t
  2. where t.create_time >=TRUNC(SYSDATE, 'MM')
  3. and t.create_time<=last_day(SYSDATE)
Java代码
  1. create_time为你要查询的时间

当年数据

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

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

Java代码
  1. where t.create_time >=trunc(sysdate, and t.create_time<=trunc(sysdate,

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

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