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

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

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

select b.emp_no,a.salary,b.last_name,b.first_name
from salaries as a inner join employees as b on a.emp_no = b.emp_no
where salary in 
(select max(salary)
from salaries
where salary not in
(
    select max(salary)
    from salaries
))

用max找出最大值后,原表not in 排除最大值,剩下的数据使用max就是第二大值了

全部评论

相关推荐

03-18 09:45
莆田学院 golang
牛客749342647号:佬,你这个简历模板是哪个,好好看
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务