select name,
sum(
case score
when N'胜' then 1
else 0
end
) as '胜',
sum(
case score
when N'败' then 1
else 0
end
) as '败' from table2 group by name
![](http://hi.csdn.net/attachment/201111/15/0_132137005991U6.gif)
![](http://hi.csdn.net/attachment/201111/15/0_1321370068HDrz.gif)
select name,
sum(
case score
when N'胜' then 1
else 0
end
) as '胜',
sum(
case score
when N'败' then 1
else 0
end
) as '败' from table2 group by name