Skip to content

Commit 53c9369

Browse files
refactor 570
1 parent 96c3161 commit 53c9369

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

Diff for: database/_570.sql

-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
--570. Managers with at Least 5 Direct Reports
2-
--The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.
3-
--
4-
--+------+----------+-----------+----------+
5-
--|Id |Name |Department |ManagerId |
6-
--+------+----------+-----------+----------+
7-
--|101 |John |A |null |
8-
--|102 |Dan |A |101 |
9-
--|103 |James |A |101 |
10-
--|104 |Amy |A |101 |
11-
--|105 |Anne |A |101 |
12-
--|106 |Ron |B |101 |
13-
--+------+----------+-----------+----------+
14-
--Given the Employee table, write a SQL query that finds out managers with at least 5 direct report. For the above table, your SQL query should return:
15-
--
16-
--+-------+
17-
--| Name |
18-
--+-------+
19-
--| John |
20-
--+-------+
21-
--Note:
22-
--No one would report to himself.
23-
241
select Name from Employee as Name where Id in
252
(select ManagerId from Employee group by ManagerId having count(*) >= 5)
263
;

0 commit comments

Comments
 (0)