获取当前薪水第二多的员工的emp_no以及薪水salary
获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
https://www.nowcoder.com/practice/c1472daba75d4635b7f8540b837cc719
-- 条件:当前员工,to_date='9999-01-01' -- 不能使用order by ,则窗口函数无法用,以及排序后 limit 1 offset 1 也无法用 -- 小于最大薪水的记录中的最大薪水记录,则是第二大薪水 with zjtable as ( select emp.emp_no ,salary ,last_name ,first_name from employees as emp left join salaries as sal on emp.emp_no=sal.emp_no where to_date='9999-01-01' ), ztab as ( select emp_no ,salary ,last_name ,first_name from zjtable where salary<(select max(salary) from zjtable) ) select emp_no ,salary ,last_name ,first_name from ztab where salary=(select max(salary) from ztab)