题解 | #统计每种性别的人数#

统计每种性别的人数

https://www.nowcoder.com/practice/f04189f92f8d4f6fa0f383d413af7cb8

select
    substring_index (profile, ',', -1) as gender,
    count(*) as number
from
    user_submit
group by
    gender;
select
    case
        when profile like '%,male' then 'male'
        when profile like '%,female' then 'female'
        else '其他'
    end as gender,
    count(*) as number
from
    user_submit
group by gender;

substring_index其实挺好用的

全部评论

相关推荐

头像
11-21 11:39
四川大学 Java
是红鸢啊:忘了还没结束,还有字节的5k 违约金
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务