Alternative approach to correlated sub queries
We are using Zoho Analytics with data from Xero, we wish to show the bank account balances per day, charted over 30 days.
To do this we need the sum of all account transactions to date grouped by account and day. How can I achieve this?
I would normally approach this in SQL with a correlated sub query, something like this:
- SELECT
- a."Account ID",
- a."Bank AccountType",
- a."BankAccountNumber",
- a."Name",
- j."Journal Date",
- j."Converted Net Amount",
- (SELECT SUM(JournalsInner."Converted Net Amount") FROM "Journals" as JournalsInner WHERE JournalsInner."Account ID" = a."Account ID" AND JournalsInner."Journal Date" <= j."Journal Date") as BalanceToDate
- FROM
- "Accounts" a
- INNER JOIN "Journals" j ON a."Account ID" = j."Account ID"
I understand that correlated sub queries won't work for query tables so how can I achieve this?
Many thanks
Simon