题解 | #分群并计算群体人数#

分群并计算群体人数

https://www.nowcoder.com/practice/24319fd5c03e482c935783107114933d

划分年龄段(when xx then xx end age_group)之后对年龄段分组(group by age_group) ,然后计算分组数量(count(*)user_count)
select
case
when age > 50 then '50以上' 
when age > 20 then '20-50' 
when age < 50 then '20以下' 
else '未填写' 
end age_group,
count(*)user_count 
from customers_info
group by age_group

全部评论

相关推荐

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

创作者周榜

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