有排序必有窗口函数
select avg(salary)
from
(select *,rank()over(order by salary) r from salaries where to_date='9999-01-01') a
where a.r!=1 #排除第一名
and a.r!=(select count(salary) from salaries where to_date='9999-01-01')
#排除最后一名,这里子查询算出总共有多少名的数量,正序的话名次=总数即为最后一名