分类统计:
select f.NAME ,
sum(case when f.TYPE='0' then 1 end ) as jzTotal,
sum(case when f.TYPE='1' then 1 end ) as kcTotal,
sum(case when f.TYPE='2' then 1 end ) as jwTotal,
count(f.TYPE) as Total
from r_test f group by f.NAME ;
在sum中可以加上case when then end 加上统计条件