题解 | #avg() min() max()#
平均工资
https://www.nowcoder.com/practice/95078e5e1fba4438b85d9f11240bc591
select avg(salary) avg_salary
from salaries
where to_date = '9999-01-01'
and salary <> (select max(salary) from salaries where to_date = '9999-01-01')
and salary <> (select min(salary) from salaries where to_date = '9999-01-01')
本题可以先通过 min
和 max
两个函数分别找出当前在职员工的最小和最大工资,之后将其余在职员工的工资不等于这两个最值进行 avg
聚合即可。