将两个连接替换为一个

时间:2017-09-20 14:03:09

标签: sql sql-server

我有两个加入:

LEFT JOIN TransactionAmounts AS TAR ON T.orderID = TAR.orderID AND TAR.customerType = 1
LEFT JOIN TransactionAmounts AS TAA ON T.orderID = TAA.orderID AND TAA.customerType = 0

我如何才能替换这两个连接?为了提高性能

1 个答案:

答案 0 :(得分:3)

您可以使用

column6,column7,column8

或者

LEFT JOIN TransactionAmounts AS TAR ON T.orderID = TAR.orderID AND TAP.customerType in(0, 1 )

检查执行计划