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

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

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

select
uu.uid,
count(distinct a.id) as exam_cnt,
count(distinct b.id) as question_cnt
from (
select distinct t2.uid from user_info as t1 join exam_record as t2 using(uid) join examination_info as t3 using(exam_id) 
where t1.level = 7 
and t3.tag = 'SQL' 
and t3.difficulty = 'hard'
group by t1.uid having avg(t2.score) > 80 
) as uu left join exam_record as a on uu.uid = a.uid and year(a.submit_time) = 2021 left join practice_record as b on uu.uid = b.uid and year(b.submit_time) = 2021
group by uu.uid
order by exam_cnt asc,question_cnt desc

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-27 14:11
很喜欢小米的新车,校招薪资每月22k,攒多久能买?
测试糕手手:别看工资,先看现金流存款。有50W存款以上再考虑,车是消耗品,选适合自己的重要。你有钱就当我没说过
点赞 评论 收藏
分享
06-20 19:40
中原工学院 Java
网络存储:十几天不会让你拉人办卡就结束了吧?
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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