Oracle中:
select to_char(start_time, 'YYYY-MM') as createDate,count(id) as count
from work_order
group by createDate order by createDate desc limit 12
因为 to_char 这个函数在Mysql中没有 所以在Mysql中这样查询行不通
Mysql的查询方法如下:
select DATE_FORMAT(create_time, '%Y-%m') as createDate,count(id) as count
from work_order
group by createDate order by createDate desc limit 12