MySQL一条sql语句多个count统计
MySQL一条sql语句多个count统计
·
user表:
多个count统计sql语句
select
count(case when sex ='男' then 1 end) as man,
count(case when sex ='女' then 1 end) as woman,
count(case when age>=18 then 1 end) as adult,
count(case when age<18 then 1 end) as nonage
from user
可根据自己的业务更改when后面的条件
查询结果:
更多推荐
已为社区贡献1条内容
所有评论(0)