我在这里失去了联系。在过去,我会想出一个超级 T-SQL 查询,
选择 t1.Number, t1.TransactionType, t1.Description, t1.Vendor, (Select max(t2.BatchId) From table2 t2 其中 t1.Number=t2.Number 和 t1.TransactionType=t2.TransactionType 按 t2.number,t2.transactiontype 分组)作为 BatchId 从表 1 t1
我需要 table2 中的第二列。列称为“结果”。
例子:
表格1: 编号、交易类型、描述、供应商 1、Type1、Test1、Vendor1 2、Type1、Test2、Vendor2 1、Type2、Test3、Vendor3 3、Type2、Test1、Vendor2 表2: 编号、交易类型、批次 ID、结果 1、类型1、12、错误1 1、类型1、4、错误2 1、Type2、8、成功 3、Type2、7、成功 想要的结果集: Number、TransactionType、Description、Vendor、BatchId、Result 1、Type1、Test1、Vendor1、12、error2 2、Type1、Test2、Vendor2、null、null 1、Type2、Test3、Vendor3、8、成功 3、Type2、Test1、Vendor2、7、成功
发布的查询负责前 5 列。现在最后一列怎么样?