题解 | #截取出年龄#
截取出年龄
http://www.nowcoder.com/practice/b8d8a87fe1fc415c96f355dc62bdd12f
substring_index(FIELD, sep, n)可以将字段FIELD按照sep分隔:
- 当n大于0时取第n个分隔符(n从1开始)之前的全部内容;
- 当n小于0时取倒数第n个分隔符(n从-1开始)之后的全部内容;
select substring_index(substring_index(profile, ',', 3), ',', -1) as age,
count(*) as number
from user_submit
group by age;