统计某一年中的1-12个月的数据总和
select year(now()) 年度,
sum(case when month(时间) =1 then 1 else 0 end) 一月,
sum(case when month(时间) =2 then 1 else 0 end) 二月,
sum(case when month(时间) =3 then 1 else 0 end) 三月,
sum(case when month(时间) =4 then 1 else 0 end) 四月,
sum(case when month(时间) =5 then 1 else 0 end) 五月,
sum(case when month(时间) =6 then 1 else 0 end) 六月,
sum(case when month(时间) =7 then 1 else 0 end) 七月,
sum(case when month(时间) =8 then 1 else 0 end) 八月,
sum(case when month(时间) =9 then 1 else 0 end) 九月,
sum(case when month(时间) =10 then 1 else 0 end) 十月,
sum(case when month(时间) =11 then 1 else 0 end) 十一月,
sum(case when month(时间) =12 then 1 else 0 end) 十二月
from 表 where year(时间) = year(now())
执行查询
now()当前时间,year(now()) 是当前年份,执行结果就是上图, then 1 else 0 end 意思是没有就是0填充
然后把想要的数据重装成echart图形报表数据格式填充进去即可!