题解 | 截取出年龄
截取出年龄
https://www.nowcoder.com/practice/b8d8a87fe1fc415c96f355dc62bdd12f
select
substring_index(substring_index(profile,',',-2),',',1) as age,
count(*) as number
from user_submit
group by age
也可以是
SUBSTR(str, pos, len)
str:要截取的字符串或字段名
pos:起始位置(从 1 开始;负数表示从右往左数)
len:截取的长度(可选)
SUBSTR(profile,12,2) as age 从第12字段截取两个字符
查看10道真题和解析