题解 | #查找入职员工时间排名倒数第三的员工所有信息#
查找入职员工时间排名倒数第三的员工所有信息
https://www.nowcoder.com/practice/ec1ca44c62c14ceb990c3c40def1ec6c
select emp_no, birth_date, first_name, last_name, gender, hire_date
from (
select emp_no, birth_date, first_name, last_name, gender, hire_date, dense_rank()over(order by hire_date desc) as posn
from employees
) as rk
from (
select emp_no, birth_date, first_name, last_name, gender, hire_date, dense_rank()over(order by hire_date desc) as posn
from employees
) as rk
where rk.posn = 3
-- 直接用开窗函数,思路非常清晰,先赋予排名再选出排名第三的