题解 | #SQL类别高难度试卷得分的截断平均值#
SQL类别高难度试卷得分的截断平均值
https://www.nowcoder.com/practice/a690f76a718242fd80757115d305be45
-- 用开窗函数,去掉最大和最小
select tag,difficulty,round(AVG(score),1) clip_avg_score
from(select tag,difficulty,score,
row_number() over(order by score desc) rn,
row_number() over(order by score asc) rn1
from examination_info a
inner join exam_record b
on a.exam_id=b.exam_id
where tag='SQL' and difficulty='hard' and score is not null) t
where rn <>1 and rn1<>1
group by tag,difficulty