select BQDM,sum(case when HFBZ='0' then 1 ELSE 0 end) bxschf,
sum(case when HFBZ='1' then 1 ELSE 0 end) xschf,
sum(case when HFBZ='2' then 1 ELSE 0 end) yschf,
sum(case when HFBZ='3' then 1 ELSE 0 end) xxghf
from T_ZYBR_INFO
group by BQDM
select BQDM,sum(case when HFBZ='0' then 1 ELSE 0 end) bxschf,
sum(case when HFBZ='1' then 1 ELSE 0 end) xschf,
sum(case when HFBZ='2' then 1 ELSE 0 end) yschf,
sum(case when HFBZ='3' then 1 ELSE 0 end) xxghf
from T_ZYBR_INFO
group by BQDM