select AVG(salary) avg_salary from salaries where salary not in ( select max(salary) from salaries where to_date = '9999-01-01' union all # 不去除重复记录 select min(salary) from salaries where to_date = '9999-01-01' ) and to_date = '9999-01-01'