I have three tables:
Charges
Payments
Adjustments
Each has a value, called Amount. There are no allocations done on this data, we are assuming the oldest Payments are paying the oldest Charges or Adjustments. Each Amount could be +ve or -ve.
I need to produce a report which shows the age of the debt, based on the current balance being in debt, where the balance is the sum of each Amount in all tables. However, the age of the debt must be the Age of the current debt. If an account was in debit in October, but was zeroed in November and then in Debit in February, the Age of the Debt would be February. In need to provide a 30, 60, 90 day breakdown of each account whose balance is outstanding.
Sorry if this isn't clear, but if you've done it before you'll know what I mean. Any pointers?