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: Newbie needs PL/SQL help

Re: Newbie needs PL/SQL help

From: Jens Schauder <Jens.Schauder_at_opal-edv.com>
Date: Tue, 06 Apr 1999 16:13:24 GMT
Message-ID: <01be8048$64394cb0$a870e491@wntker13-2>


The main part of your function shoul look something like this:

select avg(temperature)
into mov_avg
from city_temp
where seq_no between p_seq_no and p_seq_no - p_interval and city_symbol = p_City_symbol

parameters are prefixed by p_

The code isn't tested at all so it properbly doesn't work, but i hope you get the idea.

HTH
Jens

Jay Wright <valkyry_at_ibm.net> wrote in article <XtL26jvDWiRB-pn2-hyy2LMNv3FMY_at_slip166-72-126-205.in.us.ibm.net>...
> Does anyone have a general idea for a user created moving average
> function ?
> It would be starting with paramenters something like this
>
> TEMPERATURE NUMBER(4,2)
> CITY_SYMBOL VARCHAR2(10)
> SEQ_NO seq_no of the CURRENT_ROW, where seq_no is taken
> from the date
>
> the moving average length such as 10 days, 20 days, etc.
>
> the output of the moving avg funtion would the date selected and the
> moving avg would be the sum
> of the temperatures divided by the same number.
> example.
>
> select city, temperature,
> mov_avg (city_symbol, seq_no, 20) as ma20
> from city_temp
> where city_symbol = 'AUSTIN';
>
> any help please
>
Received on Tue Apr 06 1999 - 11:13:24 CDT

Original text of this message

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