Похоже, не так много хороших / сжатых инструкций о том, как правильно использовать скобки для обозначения имен таблиц ... и я сталкиваюсь с несколькими проблемами. Надеясь, что кто-то хочет / может помочь мне проверить следующий код:
SELECT
A.Ccode,
A.[Doc Type],
A.[Doc Number],
A.[Cross Company],
A.[Doc Date],
A.[Posting Date],
A.Period,
A.[Doc Header Text],
A.Reference,
IIf([2019_01].Cross Company] Is Not Null, [cc.vendor], [doc.vendor]) AS [SAP#],
IIf([2019_01.G/L]<>"201200", [2019_01.G/L], IIf([201200.G/L Acct] Is Not Null, [201200.G/L Acct], "500140")) AS [G/L Acct],
A.[G/L],
A.[Cost Center],
A.[WBS Element],
A.Order,
A.Plant,
A.[Purchase Doc],
A.Line,
A.[D/C],
IIf([D/C]="s", [Amount in LC]*1, [Amount in LC]*-1) AS [Amount(USD)],
A.USD,
IIf([D/C]="s", [Amount in DC]*1, [Amount in DC]*-1) AS [Amount(Doc)],
A.Curr,
IIf([D/C]="S", [Original Tax Base LC]*1, [Original Tax Base LC]*-1) AS [Tax Base LC],
A.[Loc Curr],
IIf([D/C]="S", [Original Tax Base DC]*1, [Original Tax Base DC]*-1) AS [Tax Base DC],
A.[Doc Cur],
A.User,
A.[Tax Code],
A.[Tax Jurisdiction],
A.[Entry Date]
INTO [Final 2019_01]
FROM
(
(
2019_01 AS A
LEFT JOIN CC AS X ON A.[Cross Company] = X.[Cross Company]
)
LEFT JOIN Doc AS Y ON (A.[Doc Number] = Y.[Doc Number]) AND (A.Ccode = Y.Ccode)
)
LEFT JOIN 201200 ON (A.Line = [201200].Item) AND (A.[Purchase Doc] = [201200].[Purchase Doc])
WHERE
(
(
(A.Period)="1"
)
AND
(
(A.Reference) Not Like "*TREE*"
)
AND
(
(
IIf([2019_01.G/L]<>"201200", [2019_01.G/L], IIf([201200.G/L Acct] Is Not Null, [201200.G/L Acct], "500140"))
) Not Like 132100
)
AND
(
(A.[G/L])<>"200100"
)
);