Re: Complex SQL
Date: Mon, 28 Oct 2002 15:34:00 -0500
Message-ID: <apk6ul$1f7$1_at_news.gazeta.pl>
select
dt,
(select sum(num)/count(1) from mytab m1 where m1.num<=m.num) avg
from mytab m
"Jim" <jschneider_at_kjinteractive.com> wrote in message
news:8e6a91e3.0210250837.57983b3b_at_posting.google.com...
> Maybe not so complex, but I don't know how to do it.
>
> My table is setup like this:
>
> Date Numeric Value
> -------------- --------------
> 01/02/2002 10
> 01/03/2002 17
> 01/04/2002 83
> ....
>
> What I'd like to do is to get the average (AVG) of
> the "Numeric Value" column at each date interval, with a
> single SQL statement. That is, an SQL statement that
> returns:
>
> 01/02/2002 10
> 01/03/2002 13.5 [(10 + 17)/2]
> 01/04/2002 55 [(10 + 17 + 83)/3]
>
> Thanks in advance for any help.
-- Serwis Usenet w portalu Gazeta.pl -> http://www.gazeta.pl/usenet/Received on Mon Oct 28 2002 - 21:34:00 CET