排除“一个”最大最小值,想到row_number窗口函数+子查询; 成功代码如下:(完全感觉做复杂了。。稍等看下大家怎么写的) with x as( select tag,difficulty,score,row_number() over(order by score desc ) r from( select score,tag,difficulty from exam_record a left join examination_info b on a.exam_id = b.exam_id where tag = "SQL" and difficulty = "hard" and score is not null )c ) select tag,difficulty,round(avg(score),1) as clip_avg_score from x where r != (select max(r) from x) and r != (select min(r) from x) group by tag,difficulty

京公网安备 11010502036488号