File tree 1 file changed +0
-45
lines changed
1 file changed +0
-45
lines changed Original file line number Diff line number Diff line change 1
- -- 1303. Find the Team Size
2
- --
3
- -- Table: Employee
4
- --
5
- -- +---------------+---------+
6
- -- | Column Name | Type |
7
- -- +---------------+---------+
8
- -- | employee_id | int |
9
- -- | team_id | int |
10
- -- +---------------+---------+
11
- -- employee_id is the primary key for this table.
12
- -- Each row of this table contains the ID of each employee and their respective team.
13
- -- Write an SQL query to find the team size of each of the employees.
14
- --
15
- -- Return result table in any order.
16
- --
17
- -- The query result format is in the following example:
18
- --
19
- -- Employee Table:
20
- -- +-------------+------------+
21
- -- | employee_id | team_id |
22
- -- +-------------+------------+
23
- -- | 1 | 8 |
24
- -- | 2 | 8 |
25
- -- | 3 | 8 |
26
- -- | 4 | 7 |
27
- -- | 5 | 9 |
28
- -- | 6 | 9 |
29
- -- +-------------+------------+
30
- -- Result table:
31
- -- +-------------+------------+
32
- -- | employee_id | team_size |
33
- -- +-------------+------------+
34
- -- | 1 | 3 |
35
- -- | 2 | 3 |
36
- -- | 3 | 3 |
37
- -- | 4 | 1 |
38
- -- | 5 | 2 |
39
- -- | 6 | 2 |
40
- -- +-------------+------------+
41
- -- Employees with Id 1,2,3 are part of a team with team_id = 8.
42
- -- Employees with Id 4 is part of a team with team_id = 7.
43
- -- Employees with Id 5,6 are part of a team with team_id = 9.
44
-
45
- -- # Write your MySQL query statement below
46
1
select employee_id, team_size from Employee e
47
2
left join
48
3
(
You can’t perform that action at this time.
0 commit comments