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

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

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

select uid,exam_cnt,ifnull(question_cnt,0) from
(select uid,
count(exam_record.submit_time) as exam_cnt
from exam_record
where uid in(
select uid
from user_info
join exam_record using(uid)
join examination_info using(exam_id)
where tag='SQL' and level =7
group by uid
having avg(score)>80)
and year(exam_record.submit_time)=2021 
group by uid ) as ex
left join

(select uid,
count(score)as question_cnt from
practice_record
where uid in(
select uid
from user_info
join exam_record using(uid)
join examination_info using(exam_id)
where tag='SQL' and level =7
group by uid
having avg(score)>80) and year(submit_time)=2021
group by uid)as qu
using (uid)

order by exam_cnt,question_cnt desc

全部评论

相关推荐

一表renzha:手写数字识别就是一个作业而已
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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