select projcetId,sum(case chartype when '网络' then 1 else 0 end) 网络, sum(case when chartype='网络' and typecode=1199 then 1 else 0 end) 网络1199, sum(case chartype when '地面' then 1 else 0 end) 地面, sum(case when chartype='地面' and typecode=1199 then 1 else 0 end) 地面1199, sum(case chartype when '网络QQ' then 1 else 0 end) 网络QQ, sum(case when chartype='网络QQ' and typecode=1199 then 1 else 0 end) 网络QQ1199 from table group by projcetId
sum(case when chartype='网络' and typecode=1199 then 1 else 0 end) 网络1199,
sum(case chartype when '地面' then 1 else 0 end) 地面,
sum(case when chartype='地面' and typecode=1199 then 1 else 0 end) 地面1199,
sum(case chartype when '网络QQ' then 1 else 0 end) 网络QQ,
sum(case when chartype='网络QQ' and typecode=1199 then 1 else 0 end) 网络QQ1199
from table
group by projcetId