按照性别、县名汇总人数。
统计源表PopTbl2
统计结果
语句
select pref_name as '县名',
sum(case when sex='2' then population else 0 end) as '男',
sum(case when sex='1' then population else 0 end) as '女'
from PopTbl2
group by pref_name
更多推荐
用一条SQL语句进行不同条件的统计
发布评论