Skip to content
Onsite

Managers with at least five direct reports

MediumP2Coding

Table employee:

ColumnType
idint (primary key)
nametext
manager_idint (NULL for the top of the tree)

Return the names of employees who have at least five direct reports.

Output column: name.

Schema

CREATE TABLE employee (
  id int PRIMARY KEY,
  name text NOT NULL,
  manager_id int
);

Example 1

Input
Ann (id 1) has five employees with manager_id = 1
Output
name: Ann

Constraints

  • PostgreSQL dialect.

Hints

PostgreSQL
Run checks the 3 visible tests, Submit all 6.