题解 | #SQL类别高难度试卷得分的截断平均值#
SQL类别高难度试卷得分的截断平均值
https://www.nowcoder.com/practice/a690f76a718242fd80757115d305be45
select
tag,
difficulty,
round((sum(score) - min(score) - max(score))/(count(score)-2),1)
from
(
select
examination_info.tag,
examination_info.difficulty,
exam_record.score
from
examination_info,
exam_record
where
examination_info.exam_id = exam_record.exam_id
) as newform
group by
tag,
difficulty
having
tag = 'SQL'
and difficulty = 'hard'
本题难度在于取平均数,需要先将两个表通过exam_id内连接,之后通过聚合函数将总数sum()去除min()最小值和max()最大值除以计数count()-2

查看30道真题和解析