Re: Simple SQL?

From: Larry Coon <larry_at_assist.org>
Date: Thu, 17 May 2001 15:19:10 -0700
Message-ID: <3B044E5E.6F37_at_assist.org>


Goran Sliskovic wrote:

> It will return wrong result.
> before group by result set is:
>
> a b1 b2 c1 c2
> 1 1 1 1 3
> 1 1 1 1 4
> 1 1 1 1 5
> 1 2 1 1 3
> 1 2 1 1 4
> 1 2 1 1 5
>
> So it will return 3xsum(b2) and 2xsum(c2).

Then maybe...

SELECT a, SUM(b2)/COUNT(c2), SUM(c2)/COUNT(b2) FROM tblA, tblB, tblC
WHERE a = b1 AND a = c1
GROUP BY a

Larry Coon
University of California
larry_at_assist.org
and lmcoon_at_home.com Received on Fri May 18 2001 - 00:19:10 CEST

Original text of this message