题解 | 查找入职员工时间升序排名的情况下的倒数第三的员工所有信息

查找入职员工时间升序排名的情况下的倒数第三的员工所有信息

https://www.nowcoder.com/practice/ec1ca44c62c14ceb990c3c40def1ec6c

select
    emp_no,
    birth_date,
    first_name,
    last_name,
    gender,
    hire_date
from
    (
        select
            *,
            dense_rank() over (
                order by
                    hire_date desc
            ) as rk
        from
            employees
    ) employees
where
    rk = 3
order by
    emp_no;

①where不能直接使用select的别名,需要加入子查询或者CTE

②dense_rank()窗口函数,相同值会获得相同排名,排名连续不间断,适用于“找出第N名”的需求。

全部评论

相关推荐

双尔:你就写拥有ai开发经历,熟练运用提示词,优化ai,提高ai回答质量
点赞 评论 收藏
分享
10-31 22:23
门头沟学院 Java
天然不是卷王:太好了 佬的金九银十结束,等offer吐出来,我的金11银12就要开始了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务