+---------------+---------+
#|Column Name |Type|#+---------------+---------+
#| employee_id | int |#| team_id | int |#+---------------+---------+
employee_id is the primary key for this table. Each row of this table contains the ID of each employee and their respective team. Write an SQL query to find the team size of each of the employees. Return result table in any order.
SELECT em.employee_id,
sub.total team_size
FROM Employee em
JOIN (
SELECT team_id, COUNT(*) total
FROM Employee
GROUPby team_id) sub ON sub.team_id = em.team_id;
1
2
3
SELECT employee_id,
COUNT(team_id) OVER(PARTITION BY team_id) AS team_size
FROM Employee