0
使用SQL Server 2014时,如何返回1或0的表格,然后计算1表示多个字段名称在类似表格中匹配的情况, [贷款标识符]。我目前有一张名为dbo.Tape的表格,它是原始表格,然后是dbo。[磁带捕捉],用户正在更新。两个表中的[贷款标识符]是相同的。在比较表时EXCEPT返回一个值
如果你可以帮忙,谢谢。
SELECT
[Loan Identifier], [Completion date], [Tenure], [Underwriter name]
FROM
dbo.Tape
EXCEPT
SELECT
[Loan Identifier], [Completion date], [Tenure], [Underwriter name]
FROM
dbo.[Tape Capture]
如果dbo.Tape
的[Completion date]
在dbo.[Tape Capture]
匹配[Completion date]
,那么我想返回1,否则为零。然后我想在每列中总结所有这些值。例如,
DBO [磁带中捕捉]:
[Loan Identifier], [Completion date], [Tenure], [Underwriter name]
1 01/01/2016 Freehold James Mac
2 01/01/2016 Leasehold James Mac
3 02/01/2016 Freehold James Mac
4 01/01/2016 Leasehold James Mac
5 03/01/2016 Freehold James Mac
dbo.Tape:
[Loan Identifier], [Completion date], [Tenure], [Underwriter name]
1 01/01/2016 Freehold James Mac
2 01/01/2016 Freehold James Mac
3 01/01/2016 Freehold James Mac
4 01/01/2016 Freehold James Mac
5 01/01/2016 Freehold James Mac
然后,我想结果表来保存:
[Loan Identifier], [Completion date], [Tenure], [Underwriter name]
1 1 1 1
2 1 0 1
3 0 1 1
4 1 0 1
5 0 1 1
从这里,我想总结每列中的值。
样本数据和期望的结果将有助于解释您想要做什么。完全不清楚你要找的结果。 –
嗨戈登,谢谢。我编辑了我的问题,使其更清晰。 –