select tb1.tag ,tb1.difficulty ,round(avg(tb1.score),1) from( select er.score ,ei.tag ,ei.difficulty ,row_number() over(order by er.score desc) r1 ,row_number() over(order by er.score asc) r2 from exam_record er left join examination_info ei on er.exam_id = ei.exam_id where ei.tag = "SQL" and ei.difficulty = "hard" and er.score is not null ) tb1 where tb1.r1<> 1 and tb1.r2 <> 1;