Tag: Leetcode SQL: 570 Managers with at Least 5 Direct Reports
-
Leetcode SQL: 570 Managers with at Least 5 Direct Reports
•
SELECT e.name FROM Employee e JOIN ( SELECT managerId FROM Employee WHERE managerId IS NOT NULL GROUP BY managerId HAVING COUNT(*) >= 5 ) AS ManagersWithReports ON e.id = ManagersWithReports.managerId; Explanation: Subquery – Find Managers with at Least 5 Reports: We first create a subquery to count how many direct…