HR: Manager-to-Staff Ratio

10pts
Workday, Salesforce

Problem Statement

Workday helps companies optimize their organizational structure. One key metric is the "Span of Control." If a department has too many managers relative to the number of staff members, it might be over-leveraged or top-heavy.

Write a query to find departments where the ratio of Managers to Staff is greater than 1:15 (i.e., more than 1 manager for every 15 staff members).

Rules:

  • An employee is a Manager if their job_title contains the word Manager (case-insensitive).
  • All other employees are considered Staff.
  • The ratio calculation is: (Number of Managers / Number of Staff).
  • Only include departments that have at least one Staff member to avoid division by zero.
  • Output columns: department_name, manager_count, staff_count, manager_to_staff_ratio.
  • Sort by manager_to_staff_ratio descending, then department_name ascending.
Tests your understanding of
Conditional Aggregation, Joins and Filtering

Input Tables

departments
department_id(INTEGER)department_name(VARCHAR)
1Engineering
2Sales
3Marketing
4Customer Support
employees
employee_id(INTEGER)employee_name(VARCHAR)job_title(VARCHAR)department_id(INTEGER)
101AliceEngineering Manager1
102BobSoftware Engineer1
103CharlieSoftware Engineer1
104DavidSales Manager2
105EveAccount Executive2
106FrankMarketing Director3
107GraceSupport Specialist4

Expected Output

department_name(VARCHAR)manager_count(INTEGER)staff_count(INTEGER)manager_to_staff_ratio(DECIMAL)
Sales111
Engineering120.5

Tags

HardConditional AggregationJoinsFiltering
20-30 min
39%

Hints