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

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

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

全部评论

相关推荐

给个offer灞:校友 是不是金die
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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