Hi.
I have a table name (customer_credit_history) which has columns CustomerID, month_invoiced, year_invoiced, Invoice_sales, Amt_paid. I need to capture AR balance for the lat couple years by periods and year. my biggest problem with this query is caputering the value for the previous period and adding it to the next without getting another column.
The calculation is simply (Invoice_sales - Amt_paid). I keep getting the in multiple columns when I need it all in one row.
customer 12345 bought on a 1000 and paid 200 ...
then buy: 900 Paid 500: buy for 500 Paid 500. Buy for 2000 Paid: 2200.....
Expected results:
Customer_id, Year Month AR_Bal
12345 2008 12 800
12345 2009 1 1200
12345 2009 3 1200
12345 2009 4 1000
Thanks in advance.
Our community of experts have been thoroughly vetted for their expertise and industry experience.