当前位置:网站首页>【每日SQL打卡】DAY 25丨求团队人数【难度中等】
【每日SQL打卡】DAY 25丨求团队人数【难度中等】
2022-07-29 11:42:00 【不吃西红柿】
难度简单
SQL架构
员工表:Employee
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| employee_id | int |
| team_id | int |
+---------------+---------+
employee_id 字段是这张表的主键,表中的每一行都包含每个员工的 ID 和他们所属的团队。编写一个 SQL 查询,以求得每个员工所在团队的总人数。
查询结果中的顺序无特定要求。
查询结果格式示例如下:
Employee Table:
+-------------+------------+
| employee_id | team_id |
+-------------+------------+
| 1 | 8 |
| 2 | 8 |
| 3 | 8 |
| 4 | 7 |
| 5 | 9 |
| 6 | 9 |
+-------------+------------+
Result table:
+-------------+------------+
| employee_id | team_size |
+-------------+------------+
| 1 | 3 |
| 2 | 3 |
| 3 | 3 |
| 4 | 1 |
| 5 | 2 |
| 6 | 2 |
+-------------+------------+
ID 为 1、2、3 的员工是 team_id 为 8 的团队的成员,
ID 为 4 的员工是 team_id 为 7 的团队的成员,
ID 为 5、6 的员工是 team_id 为 9 的团队的成员。边栏推荐
猜你喜欢
随机推荐
8. Interleave - understand ThreadPoolExecutor thread pool from architecture design to practice
[image processing] image skeleton extraction based on central axis transformation with matlab code
递归-八皇后问题
On CompareTo method in string
大伟 Golang之路
socket+websocket
MFC学习备忘
Out-of-the-box problem-solving thinking, putting a "rearview mirror" on the unconscious life
How to start writing helm charts for your kubernetes application
微信发红包测试用例
测试环境要多少,从现实需求说起
Self collection online computer wallpaper PHP source code v2.0 adaptive end
浅谈string中的compareTo方法
Similarities and differences of QWidget, qdialog and qmainwindow
Lucky draw system with background source code
Learning with Recoverable Forgetting阅读心得
Kubernetes基本概念
基本.分块
学习周刊-总第64期-一个v2ex风格的开源论坛程序
"Knowledge Collection" article to understand mysql index!!(recommended collection)









