Managers with at Least 5 Direct Reports
You can find the managers with at least five direct reports by using the following SQL query:
|
|
Explanation:
- In the subquery, we first filter out rows where
managerId
is null, then group the results bymanagerId
and use theHAVING
clause to filter groups that have a count of 5 or more. - In the outer query, we select the names of employees whose IDs are in the result of the subquery, yielding the names of managers with at least five direct reports.