日期:2014-05-18 浏览次数:20756 次
select 姓名,SUM((case when 类型='A' then 1 else 0 end)) as 'A', SUM((case when 类型='B' then 1 else 0 end)) as 'B', SUM((case when 类型='C' then 1 else 0 end)) as 'C' from 表 group by 姓名
------解决方案--------------------
select 姓名, sum(case when 类型='A' then 1 else 0 end) A, sum(case when 类型='A' then 1 else 0 end) B, sum(case when 类型='A' then 1 else 0 end) C from tb group by 姓名