Leetcode- 570. Managers with at Least 5 Direct Reports

르네·2023년 11월 20일
0

SQL

목록 보기
60/63

문제

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

Return the result table in any order.

풀이

WITH DirectReportsCount AS (
    SELECT managerId, COUNT(*) AS directReports
    FROM Employee
    GROUP BY managerId
    HAVING COUNT(*) >= 5
)

SELECT E1.name
FROM Employee E1
JOIN DirectReportsCount E2 ON E1.id = E2.managerId

배운점

profile
데이터분석 공부로그

0개의 댓글