Re: Iterative Calculations

From: Álvaro G. Vicario <alvaro.NOSPAMTHANX_at_demogracia.com.invalid>
Date: Fri, 14 Aug 2009 14:21:54 +0200
Message-ID: <h63lcv$2k5$1_at_news.eternal-september.org>



Hans Mayr escribió:
> I have a table that contains the fields PERIOD, STOCK, NEW_UNITS,
> CHURN_RATE. STOCK is only available for a given start period. I want
> to update the expected stock of the next periods. Is there a way that
> in pure SQL (without PL SQL and a cursor) I can calculate
>
> STOCK of PERIOD (N) = STOCK of PERIOD (N-1) * (1-CHURN_RATE) +
> NEW_UNITS
Perhaps you can use the LAG function:

http://www.adp-gmbh.ch/ora/sql/analytical/lag.html

-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Received on Fri Aug 14 2009 - 07:21:54 CDT

Original text of this message