常用sql

按条件统计四个季度的测单数量 #
select sum(case when begin>='20201226' and end<='20210325' then 1 else 0 end) as '一季度', sum(case when begin>='20210326' and end<='20210625' then 1 else 0 end) as '二季度', sum(case when begin>='20210626' and end<='20210925' then 1 else 0 end) as '三季度', sum(case when begin>='20210926' and end<='20211225' then 1 else 0 end) as '四季度' from zt_testtask where `owner`in('liqingyun','wangkl','haonan','zhanghongyun','yuping','liuth','zhaobo','zhourui','luoqing','zhaojiaqi')

  

 

posted @ 2021-12-16 16:32  小蕊-zr  阅读(10)  评论(0编辑  收藏  举报