[解决办法] select sum(case when flag='加' then 1 else 0 end) [加],sum(case when flag='回' then 1 else 0 end) [回] from tb
select flag , count(1) cnt from tb group by flag [解决办法] select sum(case when flag = '加' then 1 else 0 end) as Jflag, sum(case when flag = '回' then 1 else 0 end) as Hflag from T group by flag [解决办法] select sum(case when flag = '加' then 1 else 0 end) as Jflag, sum(case when flag = '回' then 1 else 0 end) as Hflag from T 或 select flag,count(*) as FlagNum from T group by flag