Join grootboekrekeningen en boekingsregels

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.