Re: Complex SQL

From: bruce <bruce_brodinsky_at_glic.com>
Date: 29 Oct 2002 09:58:35 -0800
Message-ID: <d3654513.0210290958.b63cd7e_at_posting.google.com>


jschneider_at_kjinteractive.com (Jim) 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.

    select t1.field1,(select avg(t2.field2) from bbtest2 t2 where t2.field1<=t1.field1) from bbtest2 t1

    sorry, you'll have to translate that out to your field names, I did test this.... Hope it helps you. Received on Tue Oct 29 2002 - 18:58:35 CET

Original text of this message