当前位置:网站首页>【每日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 的团队的成员。边栏推荐
猜你喜欢
随机推荐
惠及6亿人 投资98亿 沿江高铁武宜段最新进展来了!
谷歌“消灭” Cookie 计划延至 2024 年
使用anyio替代asyncio
After connect and SQL join in on conditions and where
共建共享数字世界的根:阿里云打造全面的云原生开源生态
1.4、栈
Self collection online computer wallpaper PHP source code v2.0 adaptive end
"100 Interview Knowledge Collections" 1. Interview Skills丨Do you really understand HR's careful thinking?
PaddleLite 编译以及代码跑通复盘
Paddlelite compilation and code running through the disk
Learn weekly - 64 - a v2ex style source BBS program
Why should kubernetes be used in development environments
微信发红包测试用例
如何使用“COPY –link”加速 Docker 构建和优化缓存
Collections.singletonList(T o)
AI model risk assessment Part 2: core content
golang 实现文件上传下载
【表达式计算】表达式计算问题的通用解法(练习加强版,含总结)
Mall mall based on flask --- user module
SkiaSharp of WPF custom painting to bounce ball (case)








