请问如何实现统计一周内的数据,一月内的数据等等!
例如有一张表(A),A表假设就有两个字段:ID,Data。
怎么判断data是在一周内,一月内。一年内的数据总和

解决方案 »

  1.   

    有一个时间字段,就是data这个
      

  2.   

    例如有一张表(A),A表假设就有两个字段:ID,Data
    时间哪里体现
      

  3.   

    周就不晓得,
    月:select * from A where to_char(date,'yyyymm')='200911'
    年:select * from A where to_char(date,'yyyy')='2009'
      

  4.   

    不管什么数据,这只是一个假设而已嘛!
    统计总量,count就可以了,不用管具体的东西
      

  5.   

    一周内的应该是
    select * from table1 where datetime>sysdate-7
    一年内的
    select * from table1 where datetime>add_months(sysdate,-12)
    一月内
    where datetime>add_months(sysdate,-1)本周内
    where to_char(datetime,'yyyyiw')=to_char(sysdate,'yyyyiw')
    本年内
    where datetime>=trunc(sysdate,'yyyy')
    本月内
    where datetime>=trunc(sysdate,'mm')
      

  6.   

    ----- 查今天是 "今年" 的第几周
    select to_char(sysdate,'ww') from dual;查询45周的记录
    周:select * from A where to_char(date,'ww')='45' 
      

  7.   

    按月:
    select to_char(times ,'yyyy-MM') ,count(*) from times group by to_char(times,'yyyy-MM');
    按年
    select to_char(times ,'yyyy') ,count(*) from times group by to_char(times,'yyyy');
    按周 最笨的办法就是用between ...