题解 | #获取当前薪水第二多的员工的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;

全部评论

相关推荐

点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-01 11:47
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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