create table pp(類別 nvarchar(10),id int ,是否免收 int, 金額 int )
insert pp select '1','1','0','100'
union select '2','3','1','0'
union select '2','5','0','100'
union select '3','6','1','0'
select * from pp
select 類別,sum(case 是否免收 when '0' then 1 else 0 end) as 非免收人數,
sum(case 是否免收 when '0' then 0 else 1 end) as 免收人數,sum(金額) as 金額 from pp group by 類別
drop table pp