请教这个的SQL如何写呢
请问这个的SQL怎么写呢?

前面两个还好说,就是后面的麻烦,不用存储过程就用一条SQL语句实现
------解决方案--------------------
select 上报人,count(是否有效)[总数],count(case when 是否有效='有' then 1 else null end )[有效数],count(case when 是否有效='无' then 1 else null end )[无效数]
from tb
group by 上报人
------解决方案--------------------
select 上报人,count(是否有效)[总数]
,count(case when (得分<>1 AND 状态=1) then 1 else null end )[有效数]
,count(case when (得分=0 AND 状态=0) then 1 else null end )[无效数]
from tb
group by 上报人
------解决方案--------------------
改一下不就行了?
------解决方案--------------------
前面两个还好说,就是后面的麻烦,不用存储过程就用一条SQL语句实现
------解决方案--------------------
select 上报人,count(是否有效)[总数],count(case when 是否有效='有' then 1 else null end )[有效数],count(case when 是否有效='无' then 1 else null end )[无效数]
from tb
group by 上报人
------解决方案--------------------
select 上报人,count(是否有效)[总数]
,count(case when (得分<>1 AND 状态=1) then 1 else null end )[有效数]
,count(case when (得分=0 AND 状态=0) then 1 else null end )[无效数]
from tb
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 上报人