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

统计每种性别的人数

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

思路: 使用subString_index截取指定字符串,再分组即可

下面是 subString_index的用法:

substring_index(str,delim,count),str是要截取的字符串,delim是截取的字段 count是从哪里开始截取(为0则是左边第0个开始,1位左边开始第一个选取左边的,-1从右边第一个开始选取右边的
                                                                       
select SUBSTRING_INDEX(profile,",",-1) gender,count(profile) number
from user_submit GROUP by gender
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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