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

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

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

# 子查询筛选红名大佬,左连接匹配
select uid
,count(score) as exam_cnt
,ifnull(t2.question_cnt,0)
from exam_record 
left join
(select uid
,count(score) as question_cnt
from practice_record 
where submit_time like "2021%"
group by uid) as t2 using(uid)

where uid in
(select exam_record.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)
and submit_time like "2021%"
group by uid
order by exam_cnt,question_cnt desc

全部评论

相关推荐

走不到的路就这样算了吗:大佬硬气
点赞 评论 收藏
分享
一名愚蠢的人类:多少games小鬼留下了羡慕的泪水
投递荣耀等公司10个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-26 16:06
已编辑
快手电商 后端 23k-35k
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务