select xx,
sum(case when yy=1 then 1 else 0 end) [1的次数],
sum(case when yy=2 then 1 else 0 end) [2的次数]
from 表
sum(case when yy=1 then 1 else 0 end) [1的次数],
sum(case when yy=2 then 1 else 0 end) [2的次数]
from 表
调试欢乐多
from 表
當count(*)為1時值為100,2時300,3時600,4時900,5時1200