题解 | #计算25岁以上和以下的用户数量#

计算25岁以上和以下的用户数量

http://www.nowcoder.com/practice/30f9f470390a4a8a8dd3b8e1f8c7a9fa

分析思路:
1.将用户划分成25岁以上和25岁以下用户
select case when age >= 25 then '25岁及以上'
                    else '25岁以下' end age_cut
     from user_profile
2.将查询到的结果作为表,再进行分组,并使用聚合函数count

解题思路:
select age_cut,count(*) "number"
from (select case when age >= 25 then '25岁及以上'
                    else '25岁以下' end age_cut
     from user_profile
     ) t_age_cut
group by age_cut;


全部评论

相关推荐

01-20 10:59
中北大学 运营
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务