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

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

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

select ui.uid , count(distinct er.exam_id) exam_cnt,count(distinct pr.submit_time) question_cnt
from user_info ui join exam_record er using(uid)
join examination_info ei using(exam_id) 
left join practice_record pr using(uid)
where ui.uid in
(
select ui.uid uid
from user_info ui join exam_record er using(uid)
join examination_info ei using(exam_id)
where ei.tag="SQL" and ei.difficulty= "hard" and ui.level=7 
and exists (select * from exam_record where exam_record.uid=ui.uid and year(exam_record.submit_time)=2021)
group by ui.uid
having avg(er.score)>80
) and year(er.submit_time)=2021 and (year(pr.submit_time)=2021 or pr.submit_time is null)
group by ui.uid
order by exam_cnt asc,question_cnt desc

全部评论

相关推荐

11-15 18:39
已编辑
西安交通大学 Java
全村最靓的仔仔:卧槽,佬啥bg呢,本也是西交么
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务