题解 | #查找排除当前最大、最小salary之后的员工的平均工资avg_salary#
查找排除当前最大、最小salary之后的员工的平均工资avg_salary
http://www.nowcoder.com/practice/95078e5e1fba4438b85d9f11240bc591
可以采用多表工作,即剔除最大值和最小值后的新表中计算avg:
select avg(s1.salary) as 'avg_salary'
from salaries s1
where salary not in (select MAX(salary) from salaries s2 where s2.to_date = '9999-01-01')
and s1.salary not in (select MIN(salary) from salaries s2 where s2.to_date = '9999-01-01')
and s1.to_date = '9999-01-01'
;
