题解 | 截取出年龄
截取出年龄
https://www.nowcoder.com/practice/b8d8a87fe1fc415c96f355dc62bdd12f
解析:substring_index的组合使用 获取中间位置的数据
使用分段截取思想 先将需要的数据截取成 在头或在为的形式
最后再根据在头 还是为 使用 1 或 -1 截取
select
substring_index(
substring_index(profile,',',-2),',',1) as age,
count(*) as number
from user_submit
group by age;
查看7道真题和解析