题解 | 截取出年龄
截取出年龄
https://www.nowcoder.com/practice/b8d8a87fe1fc415c96f355dc62bdd12f
select
substring_index(substring_index(profile, ',', 3), ',', -1) as age,
count(device_id) as number
from
user_submit
group by
age
- substring_index(profile, ',', 3), 按照‘,’分割,此处用的是正数,所以得到的是第三个‘,’前面的部分
- substring_index(substring_index(profile, ',', 3), ',', -1), 按照‘,’分割,此处用的是负数,所以得到的是最后一个‘,’后面的部分