SQL
All Top 50 SQL Interview Questions#36
Managers with at Least 5 Direct Reports in SQL
MediumAmazonInterview Question #36
Asked at AmazonGiven an `employee` table (id, name, department, managerId), find the managers who have at least 5 direct reports.
Input Table: employee
6 rows preview| id | name | managerId |
|---|---|---|
| 101 | John | NULL |
| 102 | Dan | 101 |
| 103 | James | 101 |
| 104 | Amy | 101 |
| 105 | Anne | 101 |
| 106 | Ron | 101 |
Expected Output Structure1 rows
| name |
|---|
| John |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.