select
e.emp_no emp_no,
salary,
last_name,
first_name
from
employees e
join salaries s on e.emp_no = s.emp_no
where
salary = (
select
max(salary)
from
salaries
where
salary < (
select
max(salary)
from
salaries
where
to_date = '9999-01-01'
)
and to_date = '9999-01-01'
)
and to_date = '9999-01-01'
SQL运算逻辑从里到外,表头字段名唯一可不用加表名前缀

京公网安备 11010502036488号