SELECT *
FROM AccountTransactions AS inv
INNER JOIN [Accounts basic] a2 ON inv.AccountId = a2.ID
JOIN ( SELECT *
FROM ( SELECT *,
ROW_NUMBER() OVER ( PARTITION BY AccountTransactionId ORDER BY ProcessDate ) AS RowId
FROM dbo.BillingTransactions
) Tmp
WHERE RowId = 1
) b ON inv.TransactionId = b.AccountTransactionId
more...
No comments:
Post a Comment