基本连接和聚合?
我有表 A、表 B 和表 C。
我想从表 A 中选择 2 个字段,从表 B 中选择一个字段(我假设这两个字段之间存在内部联接)以及表 B 上的标识符所在的每条记录的计数在表 C 上找到。
所以我将:
OpeartiveId | OperativeNumber | JobLocation | CountOfJobIdInWorkTable
编辑:
Operative
OperativeId
OperativeNumber
Jobs
JobId
JobLocation
Work
JobId
OperativeId
I have table A, table B and table C.
I want to select 2 fields from table A, one field from table B (an inner join between these two I'm assuming) and the Count for each record where the identifier on table B is found on table C.
So I'll have:
OpeartiveId | OperativeNumber | JobLocation | CountOfJobIdInWorkTable
Edit:
Operative
OperativeId
OperativeNumber
Jobs
JobId
JobLocation
Work
JobId
OperativeId
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
假设您还想要 a 和 b 中的记录在 c 中没有匹配的记录,则需要一个外连接:
Assuming you also want records from a and b that have no matching records in c, you'll need an outer join:
将其转换为您的实际架构并尝试:
Translate this to your actual schema and try it:
不确定这是否是您要找的。看着你提供的文件,我想出了这个。
Not sure if this is what you looking for. looking at the filed you provided i came up with this.