本题的两个需要注意点的
1.当前最大、最小 salary,则必须有条件to_date='9999-01-01';
2.先求出 max(salary)、min(salary);
2.排除最大、最小,则 where 条件为 salary 不在 max(salary),min(salary) 中,还要再加一个 to_date='9999-01-01'
select avg(salary) as avg_salary
from salaries
where salary not in ((select max(salary)
from salaries
where to_date='9999-01-01'),
(select min(salary)
from salaries
where to_date='9999-01-01'))
and to_date='9999-01-01'
京公网安备 11010502036488号