sql 统计查询(按月统计)

--String 类型 转化为 年月日  yyyy-mm-dd      to_date(substr(t.submit_time,1,10)))

如果统计一年  需要用  left  join 

(select level mymonth from dual
connect by level<13) n  

left join  (

select  extract(month from to_date(v.CHECK_TIME,'yyyy-mm-dd hh24:mi:ss')) as  tmonths from table_name v

group by extract(month from to_date(v.CHECK_TIME,'yyyy-mm-dd hh24:mi:ss')) 

ORDER BY tmonths  ) m  on  m.tmonths  =n.mymonth 

原文地址:https://www.cnblogs.com/xkoko/p/9377658.html