Oracle 数据库统计本年、本月、 本周的数据

兮城

关注

阅读 134

2022-03-24


  • 本周
    select count(*) from 表 where time > sysdate - (to_char(sysdate-1,’D’))
    其中,time为数据表中的时间对应字段


–本周申请总数
select count(*) from lzcity_approve_control_info where begin_date > sysdate - (to_char(sysdate-1,’D’));


  • 本月
    select count(*) from 表 where time>=TRUNC(SYSDATE, ‘MM’) and time<=last_day(SYSDATE)
    其中,time为数据表中的时间对应字段


–本月申请数
select count(*) from lzcity_approve_control_info where begin_date>=TRUNC(SYSDATE, ‘MM’) and begin_date<=last_day(SYSDATE);


  • 本年
    select count(*) from 表 where to_char(time,’yyyy’)=to_char(sysdate,’yyyy’)
    其中,time为数据表中的时间对应字段


–今年申请数
select count(*) from lzcity_approve_control_info where to_char(begin_date,’yyyy’)=to_char(sysdate,’yyyy’);




精彩评论(0)

0 0 举报