https://blog.csdn.net/qq_36631580/article/details/106771939
第一种方法:
SELECT user.sex, count(user.sex) as 总数 FROM test.user group by user.sex;
第二种方法:
select
sum(case when sex = '男' then 1 elase 0 end) 男生人数,
sum(case when sex = '女' then 1 elase 0 end) 女生人数
from test.user
说明:
sum(case when sex = '男' then 1 else 0 end) 男生人数 # 假如说sex=男,则结果数+1,否则+0