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

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

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

select
a.uid,
exam_cnt,
if(question_cnt is null,0,question_cnt)

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






全部评论

相关推荐

不愿透露姓名的神秘牛友
10-12 10:48
已编辑
秋招之苟:邻居家老哥19届双2硕大厂开发offer拿遍了,前几天向他请教秋招,他给我看他当年的简历,0实习实验室项目技术栈跟开发基本不沾边😂,我跟他说这个放在现在中厂简历都过不了
点赞 评论 收藏
分享
无敌虾孝子:喜欢爸爸还是喜欢妈妈
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务