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

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

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




全部评论

相关推荐

wuwuwuoow:Redisson 写错了,记得 Redis 儿子以后都不会写错。其他没啥问题,海投就行。
点赞 评论 收藏
分享
JamesGosling1:同一个公司的实习为什么写三次,就算是不同的小组的话,直接写一段要好点吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务