Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: exponential average

Re: exponential average

From: Brian E Dick <bdick_at_cox.net>
Date: Mon, 16 Dec 2002 15:13:52 GMT
Message-ID: <Q4mL9.32187$0b.1277768@news2.east.cox.net>


I believe the following does it for n=60 and a=0.5.

select a.hit_day
, sum(b.hits * power(0.5, a.hit_day - b.hit_day)) / sum(power(0.5, a.hit_day - b.hit_day)) exp_avg from daily_hits a
, daily_hits b
where b.hit_day between a.hit_day - 59 and a.hit_day group by a.hit_day

"Laly" <laly.kattoor_at_freesbee.fr> wrote in message 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 Mon Dec 16 2002 - 09:13:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US