题解 | 平均工资
平均工资
https://www.nowcoder.com/practice/95078e5e1fba4438b85d9f11240bc591
方法一 select avg(salary) from salaries join (select max(salary) maxs,min(salary) mins from salaries where to_date = '9999-01-01')h where to_date = '9999-01-01' and salary!= h.maxs and salary!=h.mins 此方法会把相同的多个最高和最低都去除,因此要根据实际业务调整 方法二 SELECT (SUM(salary) - MAX(salary) - MIN(salary)) / (COUNT(1)-2) avg_salary FROM salaries where to_date = '9999-01-01'; 此方法就可以只去除一个最高和一个最低
查看7道真题和解析