数据如下:
我想统计nfxx和nfxx2各有多少报名人数:
select count(1) rs from a group by nfxx,nfxx2得到的是两列,望大神解决,谢谢。
------解决思路----------------------
SELECT nfxx,COUNT(1)
FROM(SELECT nfxx FROM a WHERE nfxx<>''
UNION ALL SELECT nfxx2 FROM a WHERE nfxx2<>'')T
GROUP BY nfxx
------解决思路----------------------
select case when nfxx='' then nfxx2 else nfxx end , count(*)
from t
group by case when nfxx='' then nfxx2 else nfxx end