recursive formula help please!

From: Totti <saliba.toufic.george_at_gmail.com>
Date: Sat, 12 Jan 2008 15:09:48 -0800 (PST)
Message-ID: <18a4dff3-e14b-4197-aaa7-44b86967e31a@s19g2000prg.googlegroups.com>


hi all, i have a sales table that i want to get the balance for some specific condition products,
i am getting the wrong balance since i lack the knowledge of how to do a recursive formula, you may know that the balance of FEB for instance depends on JAN so on and so forth so my best attempt to solve the problem was the following, but it is still wrong, can anybody please help me correct it?

select TO_CHAR(purinv_1.Inv_Date,'mm') || ' - ' || TO_CHAR(purinv_1.Inv_Date,'yy') as "MONTH", sum(purch_1.qty*purch_1.unit_price) "Total Purchases", sum(sales_1.qty*prod_1.unit_price) "Total Sales",
(sum(purch_1.qty*purch_1.unit_price))-
(sum(sales_1.qty*prod_1.unit_price))as "Balance"

from purch_1, sales_1, prod_1, salinv_1,purinv_1
where prod_1.code=sales_1.prod_code
and salinv_1.code = sales_1.inv_code
and salinv_1.cust_code='Cu-30.1'

group by TO_CHAR(purinv_1.Inv_Date,'mm'), TO_CHAR(purinv_1.Inv_Date,'yy')
order by TO_CHAR(purinv_1.Inv_Date,'yy')

this makes only a monthly balance but this is not what i want, i want to tie it to the present balance, or to the sum of previous balances;

Thanks in advance for any help; Received on Sat Jan 12 2008 - 17:09:48 CST

Original text of this message