select avg(a.salary) avg_salary
from salaries a
where a.to_date='9999-01-01'
and a.salary not in (select max(b.salary) from salaries b where b.to_date='9999-01-01')
and a.salary not in (select min(b.salary) from salaries b where b.to_date='9999-01-01');

其中,最大值要限定是to_date='9999-01-01' 时的最大值,最小值要限定是to_date='9999-01-01'的最小值,然后求平均即可,本题主题意思不明确或者说是与答案根本不符,本题没有说明要去掉to_date='9999-01-01'这个条件下的最大、最小值,所以很多人就编译不通过。