Skip to content

3057. Employees Project Allocation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
WITH
  EmployeesWithAvgWorkload AS (
    SELECT
      Employees.employee_id,
      Employees.name AS employee_name,
      Project.project_id,
      Project.workload AS project_workload,
      AVG(workload) OVER(PARTITION BY team) AS avg_team_workload
    FROM Project
    INNER JOIN Employees
      USING (employee_id)
)
SELECT
  employee_id,
  project_id,
  employee_name,
  project_workload
FROM EmployeesWithAvgWorkload
WHERE project_workload > avg_team_workload
ORDER BY 1, 2;