题解 | 使用 count 获取第二高的工资
获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
http://www.nowcoder.com/practice/c1472daba75d4635b7f8540b837cc719
select
s.emp_no ,
s.salary ,
(select last_name from employees e where e.emp_no = s.emp_no) last_name,
(select first_name from employees e where e.emp_no = s.emp_no) first_name
from
salaries s
where
s.salary =
(
select
a.salary
from
salaries a , salaries b
where
a.emp_no <> b.emp_no
and a.salary < b.salary
group by a.salary
having count(a.salary) = 1
)