Ok what I am trying to is I have an account statement that works fine except the client now wants to see 30/60/90 day totals for the accounts,
90+ days: Total purchases over 90 days old less payments made since then
31-60 days: Total purchases over 30 days old and less than 60 days old less payments made since then (less the money used to offset 90 day old accounts)
1-30 days: Total purchases less than 30 days old less payments made since then (less the money used to offset 90 day old accounts and the 30-60 day accounts)
the attached image is the table where all account transactions are made, it is easy enough for me to get all purchases between a period but what I am having problems with is then calculating after purchases etc are taken into account. Any suggestion on writing this query would be great, btw I cannot change the format of the db as it is a 3rd party piece of software and I am just trying to write reports that read information from it.
Jason
90+ days: Total purchases over 90 days old less payments made since then
31-60 days: Total purchases over 30 days old and less than 60 days old less payments made since then (less the money used to offset 90 day old accounts)
1-30 days: Total purchases less than 30 days old less payments made since then (less the money used to offset 90 day old accounts and the 30-60 day accounts)
the attached image is the table where all account transactions are made, it is easy enough for me to get all purchases between a period but what I am having problems with is then calculating after purchases etc are taken into account. Any suggestion on writing this query would be great, btw I cannot change the format of the db as it is a 3rd party piece of software and I am just trying to write reports that read information from it.
Jason