데이터 분석

570. Manager with at Least 5 Direct Reports | Medium 본문

SQL/leetcode

570. Manager with at Least 5 Direct Reports | Medium

딱한아이 2025. 1. 21. 15:00
문제

 

Write a solution to find managers with at least five direct reports.

테이블 정보

 

5명 이상의 직속 부하 직원이 있는 관리자를 추출하는 문제이다.

 

Solutuion
SELECT name
FROM Employee
WHERE id IN (
    SELECT e.managerId
    FROM Employee e
    GROUP BY e.managerId
    HAVING COUNT(*) >= 5
)