Subject: Aggregating subsets

From: [email-masked] (Carl Feynman)
Date: Wed, 10 Mar 93 15:15:35 -0800

Here's a possibly dumb question from a beginning postgres user.  I
create a class ELT with two integer and one float attribute:

	create ELT (i=int4, j=int4, r=float4) \g

Then I define an aggregate float4ave, which I can use to find the mean
of the float4 attribute:

	retrieve (ave =  float4ave {ELT.r}) \g

This works fine.  However, what I really want is a table of the
average value of r for each different value of i.  I try this:

	retrieve (i= e.i, ave= float4ave {ELT.r where ELT.i = e.i}) 
		from e in ELT \g

and it doesn't work.  How can I do this?

--carlf