当前位置: 代码迷 >> Sql Server >> 请教此SQL怎么写
  详细解决方案

请教此SQL怎么写

热度:71   发布时间:2016-04-24 10:45:21.0
请问此SQL如何写



不用存储过程
------解决方案--------------------
select 上报人,
      count(*)总数,
      sum(case when 状态=1 then 1 else 0 end)有效数,
      sum(case when 状态=0 then 1 else 0 end)无效数
from 表
group by 上报人
------解决方案--------------------
select 上报人,
      count(*)总数,
      sum(case when 状态=1  and 得分<>1 then 1 else 0 end) '有效数',
      sum(case when 状态=0  and 得分=0 then 1 else 0 end) '无效数'
from 表
group by 上报人
  相关解决方案