select top 1
isnull((select count(*) from test),0) as 记录总数,
isnull((select count(*) from test where status='a'),0) as a的记录数量,
isnull((select count(*) from test where status='b'),0) as b的记录数量,
isnull((select count(*) from test where status='c'),0) as c的记录数量
from test
isnull((select count(*) from test),0) as 记录总数,
isnull((select count(*) from test where status='a'),0) as a的记录数量,
isnull((select count(*) from test where status='b'),0) as b的记录数量,
isnull((select count(*) from test where status='c'),0) as c的记录数量
from test
sum((case status when 'b' then 1 else 0 )) as b,sum((case status when 'a' then c else 0 )) as c form table
sum((case status when 'b' then 1 else 0 )) as b,sum((case status when 'a' then c else 0 )) as c form table
group by sid
select sid, sum(1) as total, sum((case status when 'a' then 1 else 0 end)) as a,
sum((case status when 'b' then 1 else 0 end)) as b,sum((case status when 'a' then c else 0 end)) as c form table
group by sid
sum((case status when 'a' then 1 else 0 )) as a,
sum((case status when 'b' then 1 else 0 )) as b,
sum((case status when 'c' then 1 else 0 )) as c
form table