Published on

Leetcode - 185. Department Top Three Salaries

Authors
  • avatar
    Name
    Indo Yoon
    Twitter
Table of Contents

문제

[Loading...

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

LeetCode

](https://leetcode.com/problems/department-top-three-salaries/)

정답

SELECT Department.name AS Department, Employee.name as Employee, Employee.salary AS Salary
FROM (
        SELECT *, DENSE_RANK() OVER (PARTITION BY departmentId ORDER BY salary DESC) AS n
        FROM Employee
) AS Employee
JOIN Department ON Employee.departmentId = Department.id
WHERE n <= 3