题解 | #SQL类别高难度试卷得分的截断平均值#

SQL类别高难度试卷得分的截断平均值

https://www.nowcoder.com/practice/a690f76a718242fd80757115d305be45

with a as(
select i.exam_id,max(r.score) as maxScore,min(r.score) as minScore 
from exam_record r,examination_info i 
where r.exam_id = i.exam_id and i.difficulty = 'hard' and r.score is not null
group by i.exam_id
)

select i.tag,i.difficulty,round(avg(r.score),1) from exam_record r,examination_info i 
where r.exam_id = i.exam_id and i.difficulty = 'hard' and r.score is not null
and not exists(select 1 from a where a.exam_id = i.exam_id and a.maxScore = r.score)
and not exists(select 1 from a where a.exam_id = i.exam_id and a.minScore = r.score)
group by i.tag,i.difficulty

先按科目ID分组取出最大最小的得分,然后再排除最大最小得分之后分组。

#SQL进阶#
全部评论

相关推荐

10-11 17:45
门头沟学院 Java
走吗:别怕 我以前也是这么认为 虽然一面就挂 但是颇有收获!
点赞 评论 收藏
分享
10-17 12:16
同济大学 Java
7182oat:快快放弃了然后发给我,然后让我也泡他七天最后再拒掉,狠狠羞辱他一把😋
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务