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

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

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

-- 请你找到高难度SQL试卷得分平均值大于80并且是7级的红名大佬,统计他们的2021年试卷总完成次数和题目总练习次数,只保留2021年有试卷完成记录的用户。结果按试卷完成数升序
with t as(
    select uid,exam_id,avg(score) as sc
    from exam_record 
    where year(start_time) = 2021
    group by uid,exam_id
),
a as (
    select t.uid,count(ifnull(t.exam_id,0)) as exam_cnt
from t
left join examination_info i
on t.exam_id = i.exam_id 
where t.uid in (
    select t.uid
    from t 
    left join examination_info f
    on t.exam_id = f.exam_id 
    where f.tag = 'SQL' and f.difficulty='hard' and t.sc > 80
) and t.uid in (
    select uid from user_info where level = 7
)
group by t.uid
)
select a.uid,exam_cnt,ifnull(r.question,0) as question_cnt
from a 
left join (select uid,count(question_id) as question
    from practice_record 
    where year(submit_time) =2021
    group by uid) r
on a.uid = r.uid
order by exam_cnt asc,question_cnt desc;

#SQL进阶#
全部评论

相关推荐

11-23 15:14
中原工学院 Java
程序员花海_:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
FOX2003:还没学后端框架吧,看你第一个项目用的mockjs。第一个项目太老而且可能是从github上扒的(我的课设就是这个),第二个主要依靠AI的能力,而且前端项目找前端实习的话,留个github地址好点,主要还是前端要求越来越高了。另外,去***看看,符合就投,boss投的多,HR工作量就大,没功夫多聊
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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