Skip-level managers and how many people they cover
The task
The people team plans skip-level one-on-ones. A skip-level manager is a person's manager's manager.
For every person who is the skip-level manager of at least one current employee (termination_date is NULL), count those current employees. The reporting chain is read as it is in employees: a middle manager or skip-level manager who has left still counts as part of the chain. The CEO has no manager, so people who report directly to the CEO have no skip-level manager.
Return employee_id and full_name of the skip-level manager, and skip_level_reports (the number of current employees who are two levels below them). Sort by skip_level_reports descending, then employee_id ascending.
Expected output
employee_idfull_nameskip_level_reports- Sorted by skip_level_reports descending, then employee_id ascending.
- Checked on the sample and on 2 hidden datasets. How grading works
Tables People team · click a name to insert it
departments7 rows in the sample
One row per department. Key: department_id.
| int | Unique id. | |
| text | Name. | |
| text | Main office city. |
employees120 rows in the sample
Everyone who has worked here, including people who left. Key: employee_id.
| int | Unique id. | |
| text | Name. | |
| int | Department. NULL for a few people between teams. | |
| int | Their manager (an employee_id). NULL for the CEO. | |
| text | Title. | |
| date | First day. | |
| date | Last day. NULL while employed. | |
| numeric(10,2) | Current (or final) yearly salary, USD. |
salary_changes367 rows in the sample
Every salary someone has had, from the day it applied. Key: employee_id, effective_on.
| int | The employee. | |
| date | First day of this salary. | |
| numeric(10,2) | Yearly salary, USD. |
reviews301 rows in the sample
Year-end review ratings. Key: employee_id, review_year.
| int | The employee. | |
| int | Year reviewed. | |
| int | 1 (low) to 5 (high). |
Related questions
- Colleagues hired in the same month and departmenteasy
- Products bought together in the same ordermedium
- Employees paid more than their managermedium
- Raises of 9.5 percent or more over the previous salaryhard
- Trips between a rider and a driver they already knowmedium
- How many drivers in the same city rate higherhard
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL