题解 | 平均工资

平均工资

https://www.nowcoder.com/practice/95078e5e1fba4438b85d9f11240bc591

select avg(salary) from salaries 
where 
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') and to_date = '9999-01-01' 

条件一:排除在职(to_date = '9999-01-01' )员工的最大、最小salary之后

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')

条件二:其他的在职9999-01-01在职员工的平均工资avg_salary。

to_date = '9999-01-01'

用salary去判断,可以防止最大最小salary有重复

全部评论

相关推荐

03-02 10:51
邵阳学院 Java
红鲤鱼与绿鲤鱼i:看了你的头像不像找工作,像在找妹子
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务