题解 | #计算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;


全部评论

相关推荐

搞机墨镜猫:参考一下其他人简历吧, 把项目放最上面,没有项目就展开写实习,实习项目具体做了啥,现在很空 奖项写含金量高的,还有校园经历也是,不是运营岗基本上可以都删了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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