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

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

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

# 分别统计两个记录表t1,t2,然后通过t0左连接t1,t2筛选红名大佬
select t0.uid
,ifnull(t1.exam_cnt,0) as exam_cnt
,ifnull(t2.question_cnt,0) as question_cnt
from 
(select exam_record.uid as uid
from exam_record 
join user_info using(uid)
join examination_info using(exam_id)
where difficulty="hard"
and tag="SQL"
and level=7
and submit_time like "2021%"
group by user_info.uid
having avg(score)>80) as t0
left join
(select uid
,count(score) as exam_cnt
from exam_record 
where submit_time like "2021%"
group by uid) as t1 using(uid)
left join 
(select uid
,count(score) as question_cnt
from practice_record 
where submit_time like "2021%"
group by uid) as t2 using(uid)

order by exam_cnt,question_cnt desc

全部评论

相关推荐

鱼专:别投了,我看到有人点了第二个链接投递,还没退出界面,不合适的邮件就发过来了
点赞 评论 收藏
分享
牛客63981766...:给龙虾一个固定任务,每天出去逛一圈收集消息,token就上来了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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