Join ledger accounts and booking rules

In relatie tot

Probeer ik een query te maken die boekingsregels en grootboekrekeningen samenvoegt:

Dit geeft:

itgensql035
Unknown identifier ‘t.glaccount’.
Consider one of the following: PrivateGLAccount, VATNonDeductibleGLAccount, YearEndCost…

Query:

SELECT t.glaccount, t.glaccountcode,
       (SELECT CODE
        FROM exactonlineRest#financial.Glaccountsubulk g
        WHERE g.id = t.glaccount)
FROM exactonlineRest#financialtransaction.transactionlinesbulk t

Wat doe ik fout?

Er wordt een scalar subquery gebruikt (ook bekend als correlated subquery). Deze subquery legt een relatie naar buiten de subquery.

Uit performance en query onderhoudsoverwegingen ondersteunt Invantive UniversalSQL deze vorm bewust niet.

Advies is om de query om te schrijven naar een expliciete join zoals:

select t.GLAccount
,      t.GLAccountCode
,      g.Code
from   exactonlineRest#financialtransaction.transactionlinesbulk t
join   exactonlineRest#financial.GLAccountsBulk g
on     g.ID       = t.GLAccount
and.   g.Division = t.Division

Dit is de query die Microsoft SQL Server er ook van hoort te maken.

This question was automatically closed after 1 week of inactivity. The last answer given has been marked as the solution.

Please ask a new question via a separate topic if the issue occurs again. Please include a link to this topic in the new question by pasting its URL into the text.