C小陈童鞋 2021-01-18 13:27 采纳率: 33.3%
浏览 162
已结题

MySQL根据季度进行统计,并且签名季度数据数据累加到后面

单表计算 根据下单日期(orderTime),计算季度 ,共四个季度。


问题是,季度的数据进行累加怎样实现。例如:

1-3月 是第1季度

3-6月 是第2季度 

以此类推……

现在的问题是。按季度统计数据 如下

第一季度:1-3 月

第二季度:1-6 月

第四季度:1-9 月

  • 写回答

1条回答 默认 最新

  • 奇怪丶L 2021-01-18 14:18
    关注

    sum(case when ordertime>'当年1月1日参数' and ordertime<='20210331' then ? 

             when ordertime>'当年1月1日参数' and ordertime<='20210630' then ? 

            when ordertime>'当年1月1日参数' and ordertime<='20210930' then ? 

            when ordertime>'当年1月1日参数' and ordertime<='20211231' then ? end) 

    评论

报告相同问题?