题解 | #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进阶#
全部评论

相关推荐

找不到工作死了算了:没事的,雨英,hr肯主动告知结果已经超越大部分hr了
点赞 评论 收藏
分享
牛客410815733号:这是什么电影查看图片
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务