【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 ;

参考文档:
https://blog.csdn.net/homechao/article/details/81207551?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

https://blog.csdn.net/chongmu2584/article/details/100738740?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-0&spm=1001.2101.3001.4242

上一篇下一篇

猜你喜欢

热点阅读