select
  ei.tag,
  ei.difficulty,
  round(
    (sum(er.score) - min(er.score) - max(er.score)) / (count(*) - 2),
    1
  )
from
  exam_record er
  inner join examination_info ei on er.exam_id = ei.exam_id
where
  ei.difficulty = "hard"
  and ei.tag = "SQL"
  and er.score is not null
group by
  ei.tag,
  ei.difficulty