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

select e.emp_no,max(s.salary) as salary,e.last_name,e.first_name
from employees e 
left join salaries s 
on e.emp_no = s.emp_no 
where s.to_date = '9999-01-01' and s.salary = (select max(salary) as salary from salaries where to_date = '9999-01-01' and salary<(select max(salary) from salaries where to_date = '9999-01-01'))
group by e.emp_no
;

全部评论

相关推荐

专心打鱼:举报给她开了,正好给应届生腾一个HC
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务