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

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

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


select uid,exam_cnt,if(question_cnt is null,0,question_cnt)
from
# table 1
(SELECT uid,count(submit_time) as exam_cnt
from exam_record 
where year(submit_time)=2021
group by uid) as table1
left join 
#table 2
(select uid,count(submit_time) as question_cnt
from practice_record
where year(submit_time)=2021
group by uid) as table2
using(uid)
where uid in ( #挑选哪些uid符合条件
              select uid 
              from exam_record left join user_info using(uid)
              left join examination_info using(exam_id)
              where tag = 'SQL' and level=7
              group by uid
              having avg(score)>80
)
order by exam_cnt,question_cnt desc

全部评论

相关推荐

点赞 评论 收藏
分享
11-01 08:48
门头沟学院 C++
伤心的候选人在吵架:佬你不要的,能不能拿户口本证明过户给我。。球球了
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务