๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SQL/LeetCode

[LeetCode][SQL50] #13. Managers with at Least 5 Direct Reports

by ์ด๋ฎด 2023. 11. 9.
728x90

๐Ÿ’ป ๋ฌธ์ œ ์ฃผ์†Œ : Managers with at Least 5 Direct Reports - LeetCode

 

Students and Examinations - LeetCode

Can you solve this real interview question? Students and Examinations - Table: Students +---------------+---------+ | Column Name | Type | +---------------+---------+ | student_id | int | | student_name | varchar | +---------------+---------+ student_id is

leetcode.com

 

๐Ÿ’ป ๋ฌธ์ œ

Write a solution to find managers with at least five direct reports. Return the result table in any order.

- ์ ์–ด๋„ ์ง์ ‘ ๋ณด๊ณ ๋ฅผ ์ตœ์†Œ 5๋ฒˆ ๋ฐ›์€ ๋งค๋‹ˆ์ €๋ฅผ ์ถœ๋ ฅํ•˜์‹œ์˜ค. ์ถœ๋ ฅ ์ˆœ์„œ๋Š” ์ƒ๊ด€ ์—†์Šต๋‹ˆ๋‹ค.

 

๐Ÿ’ป ์ฝ”๋“œ ๋ฐ ํ’€์ด 

select name -- ์—ฌ๊ธฐ์„œ name์€ column name
from Employee
where id in (select managerID from Employee group by managerID having count(managerID) >= 5)

 

728x90
๋ฐ˜์‘ํ˜•

'SQL > LeetCode' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[LeetCode][SQL50] #15. Not Boring Movies  (2) 2023.11.13
[LeetCode][SQL50] #14. Confirmation Rate  (0) 2023.11.13
[LeetCode][SQL50] #12. Students and Examinations  (0) 2023.11.09
[LeetCode][SQL50] #11. Employee Bonus  (0) 2023.11.08
[LeetCode][SQL50] #10. Average Time of Process per Machine  (0) 2023.11.08