Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: exponential average
Hi,
i think the best way is with PL/SQL or another programing language.
The other possible way maybe a temp. table with the terms and than
calculate the average. So you have to use a SQL-Script.
In SQL you could access to the n-1 row with a sub-query. But the sub-query also needs the row before (= n-2) and so you have to make a sub-query for the sub-query to get this value etc. This sounds like a recursive problem you can't solve in pure SQL.
I don't know if there is a standard function you can handle this - i don't
think so.
(i didn't looked at the manuals because i don't have - but i think you did
it)
"Laly" <laly.kattoor_at_freesbee.fr> schrieb im Newsbeitrag
news:4ec940f.0212111138.1658f90d_at_posting.google.com...
> Hi,
>
>
> Does anyone know how i can compute an exponential average using
> analytical functions under Oracle. It is easy to get normal moving
> average with avg(...) over(partition by ... order by ... rows 60
> preceding) but how about getting :
> x(n) + a*x(n-1) + a^2*x(n-2)+....
> -----------------------------------
> 1 + a + a^2 + ...
>
>
> More generally, is it possible to compute a column using the value
> just computed in the row before ? Something like x(n+1) = f(x(n))
> where n is the number of the row ?
>
>
> Thanks by advance for any clue.
>
>
> Laly.
Received on Sat Dec 14 2002 - 10:32:48 CST