比如,有个表中有个date字段,如何用sql返回近一年中每个月的数据量count(*),能用sql语句做到吗?谢谢大家帮忙..

解决方案 »

  1.   

    select to_char(date1,'yyyy/mm'),count(*) from table1
    group by to_char(date1,'yyyy/mm')
      

  2.   

    近一年的就select to_char(foccurdate,'yyyy/mm') d,count(*) c from wz_enterbill eb
    where eb.foccurdate>=add_months(sysdate,-11)
    group by to_char(foccurdate,'yyyy/mm')
      

  3.   

    select to_char(date,'yyyymm') as month,count(*) num from table
    group by to_char(date,'yyyymm')