select ((sum(salary)-min(salary)-max(salary))/(count(1)-2)) avg_salary from salaries where to_date='9999-01-01'