题解 | #查找排除当前最大、最小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'
;

全部评论

相关推荐

点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务