You are given two tables: Project and Employees.
The Project table contains information about project assignments with columns:
project_id(int): The project identifieremployee_id(int): The employee identifier (primary key, foreign key to Employee table)workload(int): The workload of the project for this employee
The Employees table contains employee information with columns:
employee_id(int): The employee identifier (primary key)name(varchar): The employee nameteam(varchar): The team the employee belongs to
Task: Find the employees who are allocated to projects with a workload that exceeds the average workload of all employees for their respective teams.
Return the result table ordered by employee_id, project_id in ascending order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
project_id
|
int | Project identifier |
employee_id
PK
|
int | Employee identifier (primary key, foreign key to Employees) |
workload
|
int | Workload hours for this project assignment |
| Column Name | Type | Description |
|---|---|---|
employee_id
PK
|
int | Employee identifier (primary key) |
name
|
varchar | Employee full name |
team
|
varchar | Team name the employee belongs to |
Input & Output
| project_id | employee_id | workload |
|---|---|---|
| 1 | 10 | 40 |
| 2 | 20 | 25 |
| 3 | 30 | 15 |
| 4 | 40 | 30 |
| employee_id | name | team |
|---|---|---|
| 10 | Alice | A |
| 20 | Bob | A |
| 30 | Charlie | B |
| 40 | David | B |
| project_id | employee_id | name | team | workload |
|---|---|---|---|---|
| 1 | 10 | Alice | A | 40 |
| 4 | 40 | David | B | 30 |
Team A average workload: (40 + 25) / 2 = 32.5. Alice's workload (40) exceeds this average.
Team B average workload: (15 + 30) / 2 = 22.5. David's workload (30) exceeds this average, but Charlie's (15) does not.
| project_id | employee_id | workload |
|---|---|---|
| 1 | 10 | 50 |
| employee_id | name | team |
|---|---|---|
| 10 | Alice | A |
| project_id | employee_id | name | team | workload |
|---|
Alice is the only member of team A, so her workload (50) equals the team average (50). Since she doesn't exceed the average, no rows are returned.
Constraints
-
1 ≤ project_id ≤ 1000 -
1 ≤ employee_id ≤ 1000 -
1 ≤ workload ≤ 100 -
teamnames are non-empty strings - Each employee belongs to exactly one team