scottvonduhn
07/12/2023, 4:12 PMtransactionAccountingLine to transactionLine ?
I thought this was correct
SELECT tl.transaction, tl.foreignamount, tal.credit, tal.debit
FROM transactionLine AS tl
JOIN transactionAccountingLine AS tal ON tl.transaction = tal.transaction AND tl.lineSequenceNumber = tal.transactionLine
WHERE tl.transaction = 21929383
But I have found a few cases where this gives incorrect joins. For a few transaction ids, the transactionAccountingLine has transactionLine values that don’t exist for that transaction id in transactionLine.lineSequenceNumber. For example, transactionLine has lineSequenceNumber values of 0, 1, 2, but in transactionAccountingLine, the only transactionLine values are 0, 2, 3. The 2 and 3 lines in transactionAccountingLine correspond to the 1 and 2 lines in transactionLine, respectively.
I would expect the following query to return nothing, but it returns many results:
SELECT tal.transaction, tal.transactionLine
FROM transactionAccountingLine AS tal
WHERE tal.transaction > 21920000 -- limiting for performance
AND NOT EXISTS (SELECT tl.lineSequenceNumber FROM transactionLine AS tl WHERE tl.transaction = tal.transaction AND tl.lineSequenceNumber = tal.transactionLine)
Is there any documentation as to the proper way to join these tables? Thanks so much!Zoran R-DATAGRAM
07/27/2023, 11:43 AMscottvonduhn
07/27/2023, 12:46 PMscottvonduhn
07/27/2023, 12:48 PM