Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie needs help
I suspect there is a problem in the continuity of sequence number or
the relationship of p_len to sequence number.
P-len becomes the size of the moving average, as in "the last 35 items": p_len=35 p_seq_no becomes the starting seq_no, assumes you want this flexibility to start at any point.
Sort the data descending, then gather n data points and average them.
Function awt_ma (etc,...) Return NUMBER IS
Cursor cGetData is
select close
from awt_stock_price
where symbol=p_symbol
and seq_no <= p_seq_no
order by p_seq_no DESC ;
totcnt number := 0;
wrkTot number := 0;
wrkClose number := 0;
Begin
open cGetData;
For i IN 1..p_len LOOP
Fetch cGetData into wrkClose;
Exit When cGetData%NOTFOUND;
If Close is not null Then
tot := tot + 1;
wrkTot := wrkTot + wrkClose;
End If;
End Loop;
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri May 07 1999 - 14:08:43 CDT
![]() |
![]() |