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

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

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

select uid,exam_cnt,if(question_cnt is null,0,question_cnt)
from (
select uid,count(submit_time) as exam_cnt
from exam_record
where uid in (select u.uid
            from user_info u
            join exam_record e
            using (uid)
            join examination_info
            using(exam_id )
            where level=7 and tag='SQL'
            group by u.uid
            having avg(score)>80)
     and year(submit_time)=2021
group by uid) as t1
left join (
select uid,count(submit_time) as question_cnt
from practice_record
where uid in (select u.uid
            from user_info u
            join exam_record e
            using (uid)
            join examination_info
            using(exam_id )
            where level=7 and tag='SQL'
            group by u.uid
            having avg(score)>80)
     and year(submit_time)=2021
group by uid) as t2
using(uid)
order by exam_cnt ,question_cnt desc




全部评论

相关推荐

03-12 11:54
门头沟学院 Java
dghyuiok:佬太厉害了,我也27双非,只会黑马商城和苍穹外卖,靠这两个烂大街项目,装成大三面了4个一个没中
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务