troubleshooting Question

capture AR balance for two years

Avatar of tips54
tips54 asked on
14 Comments1 Solution322 ViewsLast Modified:
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.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros