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

统计每种性别的人数

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

思考步骤:

1.从profile中拆除性别字段;

2.根据性别组合求计数。

考点:字符串截取substring_index

substring_index(str,delim,count)

  str:要处理的字符串

  delim:分隔符

  count:计数

本题我们只需要选择性别故

substring_index(profile,",",-1)
答案
select SUBSTRING_INDEX(profile,',',-1) as gender,
count(*)
FROM
user_submit
GROUP BY gender
全部评论

相关推荐

Gardenia06...:刚开始学是这样的,可以看看左神和灵神都讲的不错
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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