美文网首页
【Mysql】按季度查询结果数据累加

【Mysql】按季度查询结果数据累加

作者: 进击的程序茗 | 来源:发表于2022-01-17 14:53 被阅读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

    相关文章

      网友评论

          本文标题:【Mysql】按季度查询结果数据累加

          本文链接:https://www.haomeiwen.com/subject/gezxeltx.html