Skip to content
Advertisement

How to get Total Overdraft amounts from a particular Date in SQL

I’m trying to get the total amount of overdraft accounts from an old Date, the goal is to get the total amount it was on the 31st of January.

I have the following tables Users and Transactions.

USERS (currently)

TRANSACTIONS (daily transition can go back in time)

so the current total overdraft amount is

I need Help to reverse this amount to a date in history.

Advertisement

Answer

Assuming overdrafts are based on the sum of transactions up to a point, you can use a subquery:

The ? is a parameter placeholder for the date/time you care about.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement