oracle按天去重按月统计sql


select  substr(day,1,6)  as 月份,sum(daysum) as 用户数 from
 (select to_char(date,’yyyymmdd’) as day,count(DISTINCT an_id) as daysum from ANONYMOUS group by to_char(date,’yyyymmdd’))
  group by substr(day,1,6)

 

QQ截图20131205135109.png

 


Whatever is worth doing is worth doing well.