题解 | #截取出年龄#

截取出年龄

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

1.获取年龄,需要从profile字段中获取; 2.截取包含年龄的字符串范围substring_index(profile,',',-2),通过逗号截取,-2代表从后往前到倒数第二个逗号的位置,返回的结果是27,male;再一次截取substring_index('27,male',',',1),截取到第一个逗号前,返回:27;前两步整合得到substring_index(substring_index(profile,',',-2),',',1) as age 3.统计有多少参赛者,聚合函数count(device_id); 4.统计每个年龄的参赛者,group by age select substring_index(SUBSTRING_INDEX(PROFILE,',',-2),',',1) as age, count(device_id) from user_submit group by age

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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