【Mysql】按季度查询结果数据累加
2022-01-17 本文已影响0人
进击的程序茗
select (@csum := @csum+a.total) as total,a.time as time
from (
select count(*) as total , year(insert_time)*10000+1+100*(month(insert_time)-(month(insert_time)-1)%3) as time
from t_device_android group by year(insert_time)*10000+1+100*(month(insert_time)-(month(insert_time)-1)%3)
) a , (SELECT @csum := 0) as r ;