Employees
table by joining the reports_to
column of one instance of the table to the employee_id
column of another instance.employee_id
and name
of the manager from the first instance of the table (aliased as mgr
).COUNT
function to count the number of direct reports from the second instance of the table (aliased as emp
).AVG
function to calculate the average age of the direct reports, and use the ROUND
function to round this average to the nearest integer.employee_id
and name
to ensure that we get one row per manager.employee_id
in ascending order.erDiagram Employees { int employee_id PK "Unique employee identifier" varchar name "Employee's name" int reports_to "Manager's employee_id (null if no manager)" int age "Employee's age" }