我有一個左連接是這樣的:SQL多標識符到GROUP BY子句
LEFT MERGE JOIN --IVA0A
(SELECT VOUCHER,DATAAREAID,ISNULL(VENDTRANSID,0)AS LJT, SUM(IIF(TAXITEMGROUP = 'ANTICIPOS',-1*TAXBASEAMOUNT,TAXBASEAMOUNT))AS TAXBASEAMOUNT,
SUM(IIF(TAXITEMGROUP = 'ANTICIPOS',-1*TAXAMOUNT,TAXAMOUNT)) AS TAXAMOUNT FROM
##CPP TT
WHERE (
(TT.TAXCODE LIKE 'IVA0A' OR TT.TAXCODE LIKE 'IVA0AFA' OR TT.TAXCODE LIKE 'IVA0AEXP') OR
(TT.TAXITEMGROUP = 'ANTICIPOS' AND (TT.TAXCODE LIKE 'IVA0AP' OR TT.TAXCODE LIKE 'IVA0AFAP' OR TT.TAXCODE LIKE 'IVA0AEXPP'))
)
GROUP BY TT.VOUCHER,TT.DATAAREAID,ISNULL(LJT.VENDTRANSID,0))
AS TTIVA0A ON VT.VOUCHER = TTIVA0A.VOUCHER AND TTIVA0A.DATAAREAID = VT.DATAAREAID
and IIF(TTIVA0A.LJT=0,VT.RECID,TTIVA0A.LJT) = VT.RECID
問題是,當我試圖使用GROUP BY
條款
SQL回報:
多零件標識符「LJT.VENDTRANSID」不能被綁定。
我不明白爲什麼會發生,有誰能解釋我嗎?問候