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

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

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

弯弯绕绕的解法--自留

step 1:使用case语句查询25岁以上及以下的用户,查询结果记为table p。 step 2:对table p进行group by并联合使用count即可得出最后的结果。

select age_cut, count(*) number from 
      (select case
       when age>=25 then '25岁及以上'
       else '25岁以下'
       end age_cut 
       from user_profile) p
group by age_cut;
全部评论

相关推荐

06-10 23:36
已编辑
首都经济贸易大学 C++
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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