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

统计每种性别的人数

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

select substring_index(profile,',',-1) as gender , count(profile) as number from user_submit
group by gender

substring_index(字符串,'定位标志',第几个) :按分隔符截取字符串

解题思路:在profile中包含身高、体重、年龄和性别的信息,这些信息是用“,”隔开的,利用substring_index函数可以截取出性别的字符串。

①截取性别信息,并命名为gender:substring_index(profile,',',-1) as gender

②统计个数:count(profile)

③对性别进行分组

全部评论

相关推荐

momo_校招版:给佬跪了 我周末三场都有点嫌多了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务