You are given an Employees table containing employee information including their department ID and position.
Task: Find the name of the manager from the largest department (department with the most employees).
Important notes:
- There may be multiple largest departments when the number of employees is the same
- Return results sorted by
dep_idin ascending order - Only return managers from departments that have the maximum employee count
Table Schema
| Column Name | Type | Description |
|---|---|---|
emp_id
PK
|
int | Unique employee identifier |
emp_name
|
varchar | Employee name |
dep_id
|
int | Department identifier |
position
|
varchar | Employee position (Manager, Developer, etc.) |
Input & Output
| emp_id | emp_name | dep_id | position |
|---|---|---|---|
| 1 | Alice | 1 | Manager |
| 2 | Bob | 1 | Developer |
| 3 | Charlie | 2 | Manager |
| 4 | David | 3 | Manager |
| 5 | Eve | 3 | Developer |
| emp_name |
|---|
| Alice |
| David |
Department 1 has 2 employees (Alice, Bob), Department 2 has 1 employee (Charlie), Department 3 has 2 employees (David, Eve). The largest departments are 1 and 3 with 2 employees each. The managers of these departments are Alice and David, returned sorted by dep_id.
| emp_id | emp_name | dep_id | position |
|---|---|---|---|
| 1 | John | 1 | Manager |
| 2 | Jane | 1 | Developer |
| 3 | Mike | 1 | Analyst |
| 4 | Sarah | 2 | Manager |
| emp_name |
|---|
| John |
Department 1 has 3 employees (John, Jane, Mike) and Department 2 has 1 employee (Sarah). Department 1 is the largest with 3 employees, so we return its manager John.
| emp_id | emp_name | dep_id | position |
|---|---|---|---|
| 1 | Tom | 1 | Manager |
| 2 | Lisa | 2 | Manager |
| 3 | Rick | 3 | Manager |
| emp_name |
|---|
| Tom |
| Lisa |
| Rick |
All departments have exactly 1 employee each (all managers). Since all departments are tied for largest size, we return all managers sorted by dep_id: Tom, Lisa, Rick.
Constraints
-
1 ≤ emp_id ≤ 100 -
1 ≤ dep_id ≤ 100 -
emp_nameconsists of English letters and spaces -
positionis a valid job title including 'Manager'