select avg(salary) avg_salary
from salaries
where to_date='9999-01-01'
and salary>(select min(salary) from salaries where to_date='9999-01-01')
and salary<(select max(salary) from salaries where to_date='9999-01-01')

聚合函数只能在SELECTHAVINGORDER BY子句中使用