进行不同条件的统计是case表达式的著名用法之一
select name,sum(case when sex = 1 then population else 0 end) as cnt_m,sum(case when sex = 2 then population else 0 end) as cnt_ffrom city_population_copygroup by name
实现了行转列