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

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

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

#思路:
#①先用几次子查询把高难度SQL考试均分大于80的7级大佬选出来;
#②把各uid在21年完成考试次数求出;
#③把各uid在21年完成练题次数求出;
#④将②、③两表连接,加入筛选条件是uid在①选出的人员内即可。

select tb2.uid, a, if(b is null,0,b) question_cnt
from
(select uid, count(score) a
from exam_record 
where year(submit_time)=2021
group by uid) as tb2
left join 
(select uid, count(score) b
from practice_record 
where year(submit_time)=2021
group by uid
) as tb3
using(uid)
#下面的子查询是选出高难度SQL均分大于80的7级大佬
where uid in(
select uid 
from exam_record 
right join 
(select exam_id from examination_info where tag='SQL' and difficulty='hard') tb1
using(exam_id)
where uid in (
    select uid from user_info where level=7
)
group by uid
having avg(score)>80
)
order by a, question_cnt desc

全部评论

相关推荐

07-09 19:25
门头沟学院 Java
这是要把每一个投校招的都开盒吗?
26届之耻将大局逆转:裁人的时候一次性追回餐费
点赞 评论 收藏
分享
牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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