mysq如何l按月查询数据

select DATE_FORMAT(monitor_month,'%Y-%m') as month,sum(kwh) as kwh
from solar_monitor_year
where station_id = '1' and DATE_FORMAT(monitor_month,'%Y')='2016'
group by month
order by month 查询一年内每月的数据为什么出不来,也不报错,请各位大神指教

group by month(month)
order by month(month)

如果需要对该sql 语句做优化的话,可以参考:
MySQL如何优化GROUP BY http://www.data.5helpyou.com/article237.html

你条件里给定月份,其实对应月份的结果都已经检索出来了,不知道你是用什么语言,不管怎么样,你把查询的结果放入一个结果集中,然后从0开始
遍历,就可以了