题解 | #获取当前薪水第二多的员工的emp_no以及其对应的薪水salary#

获取当前薪水第二多的员工的emp_no以及其对应的薪水salary

http://www.nowcoder.com/practice/c1472daba75d4635b7f8540b837cc719

#先求出max工资 然后求出不等于max工资的 工资的 max值,就是第二多的薪资
select t.emp_no, t.salary, t.last_name, t.first_name 
from (select employees.emp_no, salary, last_name, first_name 
      from employees inner join salaries 
             on employees.emp_no = salaries.emp_no) as t
             where salary = 
(select MAX(salary) from 
(select salary from salaries 
where salary !=
(select MAx(salary) FROM salaries)) as s);

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-11 11:30
点赞 评论 收藏
分享
07-14 12:29
门头沟学院 Java
后端岗,实习三周感觉有点想跑路了,担心秋招被拉黑,有没有佬是字节HR知道情况的
从零开始的转码生活:你实习三周都想跑路,将来拿到offer真的愿意在这干十几二十年吗
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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