Click here to see the full article post
A simpler solution:
from Employee e1 join Employee e2
on e1.Id = e2.ManagerId
group by e1.Id
having count(e1.Id) >= 5;
select r.name from employee l join employee r on l.managerid = r.id group by l.managerid having count(1) >= 5;
Using Subquery is faster.
Employee WHERE Employee.Id IN
GROUP BY ManagerId
HAVING COUNT(ManagerId) >= 5)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.