题解 | #满足条件的用户的试卷完成数和题目练习数#

满足条件的用户的试卷完成数和题目练习数

https://www.nowcoder.com/practice/5c03f761b36046649ee71f05e1ceecbf

# select uid from user_info join exam_record using(uid) join examination_info using(exam_id)
# where level=7 and tag='SQL' and difficulty='hard'
# group by uid
# having avg(score)>80
# 找出了,SQL 高难度,均分>80的7级大佬

# count(er表score) exam_cnt left join count(pr表score) question_cnt
# 找出了,大佬们答卷数和做题数,保留答卷的全部大佬。完整如下:

select uid,exam_cnt,ifnull(qt,0) question_cnt
from (select uid,count(score) exam_cnt
from exam_record
where year(submit_time)=2021
group by uid
) t1 left join
(select uid,count(score) qt
from practice_record
where year(submit_time)=2021
group by uid
) t2 using(uid)
# 至此,找出了全部答卷者的答卷总数和练习总数
# 接下来过滤sql高难度80分+的7级大佬
where uid in(
select uid
from user_info join exam_record using(uid) join examination_info using(exam_id)
where level=7 and tag='SQL' and difficulty='hard'
group by uid
having avg(score)>80
)
order by exam_cnt,question_cnt desc

全部评论

相关推荐

10-15 10:23
门头沟学院 Java
牛可乐的头像真牛:赶紧举报,这公司绝对是诈骗的,等你签约后工作一两个月后根据合同漏洞把你开除,并且要求你赔偿3w培训费,996是为了提前筛选心甘情愿签下合同容易受骗的群体,纯粹面向校招生精心设计的骗局
你见过哪些工贼行为
点赞 评论 收藏
分享
10-31 13:04
南华大学 Java
嵌入式的小白:很多面试,面试前不会去打扰cto的,但一般cto不会在这些小事上刷人,只能说这个cto比较操心,啥重要不重要,紧急不紧急的,估计都会过问,平淡看待吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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