We help IT Professionals succeed at work.
Get Started

capture AR balance for two years

tips54 asked
Last Modified: 2012-05-07
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.
Watch Question
This problem has been solved!
Unlock 1 Answer and 14 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE