题解 | #获取当前薪水第二多的员工薪水salary#
获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
https://www.nowcoder.com/practice/8d2c290cc4e24403b98ca82ce45d04db
SELECT s.emp_no, s.salary FROM (SELECT m.emp_no, DENSE_RANK() OVER(ORDER BY salary DESC) AS rn, m.salary FROM salaries AS m) AS s WHERE s.rn = 2;
使用DENSE_RANK()OVER(ORDER BY )窗口函数,适用于有多个员工同时薪水排第二的情况。