Skip to main content

Number of Direct Reports

MediumPremium

Workday provides human capital management solutions that allow businesses to manage their employees, their roles, and the reporting structures. When Workday consultants start with a new client, one of the first things they’ll do is identify the client’s organizational structure. Each department in a company might have a manager, and under each manager, there are employees reporting directly to them.

You're given a table, employees, with the following columns:

  1. emp_id (integer): Unique identifier for each employee.
  2. emp_name (string): Name of the employee.
  3. manager_id (integer): Employee ID of the manager to whom this employee reports (can be NULL for top-level managers).

Write a SQL query that returns the Employee Id and Name of the managers who have a minimum of 2 employees directly reporting to them. Sort the results by the number of direct reports in descending order.

Your output should have the following columns: manager_employee_id, manager_name, number_of_direct_reports