Re: Simple SQL?

From: Goran Sliskovic <gsliskov_at_yahoo.com>
Date: Fri, 18 May 2001 09:02:41 +0100
Message-ID: <9e2hi2$h45$1_at_ss204.hinet.hr>


Larry Coon <larry_at_assist.org> wrote in message news:3B044E5E.6F37_at_assist.org...

> 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

Still no good :).
Now it will return 1/2sum(b2) and 1/3sum(c2). if you really want to do it without subquery, and tables have primary keys (and they should):

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

I guess this should work... too lazy to check it.

Goran Received on Fri May 18 2001 - 10:02:41 CEST

Original text of this message