select code,sum(case type when 'a' then 1 else o end)as a的个数,sum(case type when 'b' then 1 else o end)as b的个数,sum(case type when 'c' then 1 else o end)as c的个数from table...
select
code,
sum(case when type = a then 1 else 0 end) as a的个数,
sum(case when type = b then 1 else 0 end) as b的个数,
sum(case when type = c then 1 else 0 end)...