I have a table containing transactions over time, and the transactions using different bank accounts.
How d I contruct my query to tell me the balance per account at any specifc date?
My table looks like
Date Purchase Desc amount Balance Account Used
12/08/2017 item 1 500 1500 Halifax
14/09/2017 item 2 25.69 34.56 PayPal
16/09/2017 item 3 130 1630 Halifax
So If I run the query to give me my balances as at 16/09/2017 I wlll get
PayPal 14/09/2017 34.56
Halifax 16/09/2017 1630
If I get this, then I can develop it to simply give me my total balance at any specified date by summing up all last balances from every account.
I believe I need to use ROW_NUMBER () PARTITION OVER but I'm struggling with it.
This is primarily for Oracle but SQL Server (2014) also welcome.