题解 | #获取当前薪水第二多的员工的emp_no以及其对应的薪水salary#
获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
http://www.nowcoder.com/practice/8d2c290cc4e24403b98ca82ce45d04db
select
dr.emp_no,
dr.salary
from
(
select
emp_no,
salary,
DENSE_RANK() over( //在计算排序时,若存在相同次位,不会跳过之后的次位 1 1 1 2 2 3 4 排序为1 1 1 2 2 3 4
order by
salary desc
) t
from
salaries
) as dr
where
t = 2;
dr.emp_no,
dr.salary
from
(
select
emp_no,
salary,
DENSE_RANK() over( //在计算排序时,若存在相同次位,不会跳过之后的次位 1 1 1 2 2 3 4 排序为1 1 1 2 2 3 4
order by
salary desc
) t
from
salaries
) as dr
where
t = 2;