I have a table with fields - invoicenumber,customercode,invoicedate,balanceforw ard.
I want to know the sql to generate a report showing the totals for the top ten customers by total dollars outstanding, showing each invoice age range, grouped by customercode.
So if I have a table with data like so...
invoicenumber, customercode, invoicedate, balanceforward
00001 ABC 07/01/08 100.00
00002 ABC 08/01/08 150.00
00003 DEF 08/02/08 150.00
00004 ABC 09/15/08 100.00
00005 GHI 09/16/08 200.00
00006 DEF 09/16/08 100.00
00007 ABC 09/17/08 100.00
I'd like to see the data like so...
customercode, 0-30 31-60 61>
ABC 200.00 150.00 100.00
DEF 100.00 150.00 0.00
GHI 200.00 0.00 0.00
I know how to show the daysold by calculating it, but I don't know how to summarize it.
Any help with the SQL statement would be greatly apreciated.
I am running PHP on IIS accessing data on an AS400 running DB2.
I