문제
입력 코드
1. SELF JOIN
SELECT e1.name
FROM Employee AS e1
JOIN Employee AS e2
ON e1.id = e2.managerId
GROUP BY e1.id
HAVING count(e2.managerId) >= 5;
2. SUBQUERY
SELECT name
FROM Employee
WHERE id IN (
SELECT managerId
FROM Employee
GROUP BY managerId
HAVING COUNT(managerId) >= 5
)
코드 설명
#SELECT #JOIN #SELF JOIN #GROUP BY #HAVING #COUNT #SUBQUERY #IN
문제 출처
'SQL' 카테고리의 다른 글
#89. [LeetCode / MySQL] 620. Not Boring Movies (0) | 2023.09.15 |
---|---|
#88. [LeetCode / MySQL] 1934. Confirmation Rate (0) | 2023.09.14 |
#86. [LeetCode / MySQL] 1280. Students and Examinations (0) | 2023.09.12 |
#85. [LeetCode / MySQL] 577. Employee Bonus (0) | 2023.09.11 |
#84. [LeetCode / MySQL] 1661. Average Time of Process per Machine (0) | 2023.09.10 |