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

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

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

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

全部评论

相关推荐

07-11 15:12
门头沟学院 Java
别人在上班,我就在工位上看看视频啥的,这正常吗?
程序员小白条:实习就是摸鱼,只是公司指标,把你进来了,可能那时候客户很多,但等你进来的时候,已经是淡季了,根本没多少需求,或者说根本不适合实习生去完成,因此你就每天干坐着就行,可能1,2个月都没需求
实习生的蛐蛐区
点赞 评论 收藏
分享
06-25 16:25
梧州学院 Java
愿汐_:项目介绍那么长,然而你做了啥就一句话?
点赞 评论 收藏
分享
06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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