笨小孩做开发

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
select 
COUNT(case when info.State = '0' then State end  ) as daichuliCount,
COUNT(case when info.State = '1' then State end ) as yichuliCount,
COUNT(case when info.State IN('0','1') then State end) as allCount
from  cloud_crmandsupportorder as info 
where 1=1 
and DATEDIFF(info.CreateDate,NOW())=-1 
and info.UserId=''
;
select  sClass 班级,count(*)  班级学生总人数,
sum(case when sGender=0 then 1 else 0 end)  该班级女生人数,
sum(case when sGender=0 then 1 else 0 end)*1.0/count(*) 该班级女生所占比例,
sum(case when sGender=1 then 1 else 0 end)  该班级男生人数,
sum(case when sGender=1 then 1 else 0 end)*1.0 /count(*) 该班级男生所占比例  
from student GROUP BY sClass ORDER BY sClass asc
posted on 2018-08-14 14:20  笨小孩做开发  阅读(199)  评论(0编辑  收藏  举报