题解 | #作答试卷得分大于过80的人的用户等级分布#

作答试卷得分大于过80的人的用户等级分布

http://www.nowcoder.com/practice/5bc77e3a3c374ad6a92798f0ead4c744

一、明确需求:

 作答SQL类别的试卷得分>80的用户的等级分布

二、问题分解

  • 1、筛选符合条件的用户
  • 2、对输出进行调整

三、代码实现

select level,count(distinct t1.uid) level_cnt
from 
    (
    select distinct uid 
    from exam_record
    where score > 80 and exam_id in (select distinct exam_id from examination_info where tag = 'SQL')
    ) t1
left join user_info t2
    on t1.uid = t2.uid
group by t2.level
order by level_cnt desc,level desc
全部评论

相关推荐

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

创作者周榜

更多
牛客网
牛客企业服务