-- 条件:当前员工,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)