Skip to content

1077. Project Employees III 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
WITH
  RankedProjectToEmployee AS (
    SELECT
      Project.project_id,
      Project.employee_id,
      RANK() OVER(
        PARTITION BY Project.project_id
        ORDER BY Employee.experience_years DESC
      ) AS `rank`
    FROM Project
    INNER JOIN Employee
      USING (employee_id)
  )
SELECT project_id, employee_id
FROM RankedProjectToEmployee
WHERE `rank` = 1;