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

统计每种性别的人数

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

# 思路,在profile里找出来最后一个','之后是male的,就是male,其他就是female喽
# 找法:substring_index(profile,',',-1) =‘male'  这里是在profile里找‘,',-1是最后一次出现或者说从右开始第1次出现。
select case when substring_index(profile,',',-1)='male' then 'male' else 'female' end gender,count(device_id) number
from user_submit
group by gender
全部评论

相关推荐

点赞 评论 收藏
分享
AC鸽想进大厂:你是我见过最美的牛客女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务