leetcode——部门工资前三高的员工的信息

简单表组装...doge

原题链接

image.png

  • 使用rank + right join wa
  • 使用dense_rank + right join wa
  • 使用dense_rank + join AC(!Ohhhhhhhhhhh!)
SELECT RES.DName as Department,RES.Emm as Employee,RES.Salary
from (
SELECT emp.Name as Emm,
emp.Salary,
DENSE_RANK() OVER(PARTITION BY emp.DepartmentId
ORDER BY Salary DESC) as ranking,dep.Name as DName
from Employee as emp JOIN Department as dep ON emp.DepartmentId = dep.Id
)
as RES where RES.ranking <=3

最终AC QAQimage.png


标题:leetcode——部门工资前三高的员工的信息
作者:sherlockouo
地址:HTTPS://sherlockouo.com/articles/2021/07/24/1627136803146.html

    评论
    0 评论
avatar

取消