题解 | #平均工资#

平均工资

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

思路:按照题意使用 MAX/MIN + NOT IN 去除掉最大最小salary,然后算平均值。

  1. 查询在职员工的最大salary
select max(salary)
from salaries
where to_date = '9999-01-01'
  1. 查询在职员工的最小salary
select min(salary)
from salaries
where to_date = '9999-01-01'
  1. 查询在职员工的平均salary
select avg(salary)
from salaries
where to_date = '9999-01-01'
and salary not in (select max(salary) from salaries where to_date = '9999-01-01')
and salary not in (select min(salary) from salaries where to_date = '9999-01-01')
SQL练习 文章被收录于专栏

已完成牛客的SQL练习。接下来是算法的练习

全部评论

相关推荐

07-11 15:12
门头沟学院 Java
别人在上班,我就在工位上看看视频啥的,这正常吗?
程序员小白条:实习就是摸鱼,只是公司指标,把你进来了,可能那时候客户很多,但等你进来的时候,已经是淡季了,根本没多少需求,或者说根本不适合实习生去完成,因此你就每天干坐着就行,可能1,2个月都没需求
实习生的蛐蛐区
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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