搜索
您的当前位置:首页正文

MySQL统计过去12个月的数据。

来源:榕意旅游网

当前月份往前推12个月份的数据信息。

select DATE_FORMAT(cwo.create_time, '%Y-%m') as createDate, 
count(case when (cwo.process_method_code = 1 or cwo.process_method_code = 2) then 1 END) as hdCount,
count(case when cwo.process_method_code = 3 then 1 END) as siteCount
from ccs_work_order cwo
group by createDate 
order by createDate desc 
limit 12

结果展示:

因篇幅问题不能全部显示,请点此查看更多更全内容

Top