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

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

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

解题思路

  1. 筛选出tag为"SQL"并且分数大于80的exam_id
  2. 选出答过sql题目的uid,(用distinct)
  3. 在用户表中用where uid in进行限制
  4. 按level分组,level_cnt desc 排序

代码

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

相关推荐

01-30 16:13
浙江大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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