方法一:使用自关联查询

select e.emp_no, s.salary, e.last_name, e.first_name
from employees e
left join salaries s
on e.emp_no=s.emp_no
where salary=(
    select s1.salary
    from salaries s1
    left join salaries s2
    on s1.salary <= s2.salary
    group by s1.salary
    having count(distinct s2.salary)=2
)

方法二:使用子查询

select s.emp_no,s.salary,e.last_name,e.first_name
from employees e
left join  salaries s
on e.emp_no=s.emp_no
where salary=(
    select max(salary)
    from salaries s2
    where salary<(
        select max(salary)
        from salaries s3
    )
)