题解 | #获取每个部门中当前员工薪水最高的相关信息#
获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
http://www.nowcoder.com/practice/c1472daba75d4635b7f8540b837cc719
select e.emp_no,s.salary,e.last_name,e.first_name
from
employees e
join
salaries s on e.emp_no=s.emp_no
and s.salary =
(
select s1.salary
from
salaries s1
join
salaries s2 on s1.salary<s2.salary
group by s1.salary
having count(distinct s2.salary)=1
)
from
employees e
join
salaries s on e.emp_no=s.emp_no
and s.salary =
(
select s1.salary
from
salaries s1
join
salaries s2 on s1.salary<s2.salary
group by s1.salary
having count(distinct s2.salary)=1
)