题解 | #查询员工当前薪水信息,并找出薪水排名第二多的员工信息#

#查询员工当前薪水信息,并找出薪水排名第二多的员工信息
#1.查询当前员工的最高薪水
select max(salary) from salaries where to_date='9999-01-01'
#2.把最高薪水的员工排除掉,从剩下的员工信息中找出员工的最高薪水,此时这个最高薪水就是第二多薪水
select max(salary) from salaries where salary < (select max(salary) from salaries where to_date='9999-01-01')
#3.根据题目要求返回结果
select e.emp_no,salary,last_name,first_name from employees as e inner join salaries as s on e.emp_no=s.emp_no and to_date='9999-01-01' 
where salary = (select max(salary) from salaries where salary < (select max(salary) from salaries where to_date='9999-01-01'));




全部评论

相关推荐

不愿透露姓名的神秘牛友
06-04 15:20
牛客61197583...:看到室友一个个没怎么学通过关系直接入职或者接到面试,真的很难受。八股不知道背了多少遍,hot100也刷了1.5遍了,但就是没有面试的机会,唉
点赞 评论 收藏
分享
白火同学:能。我当初应届沟通了1200,收简历50,面试10左右吧,加油投吧
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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