On Wed, 2 May 2001, Jeff Meeks wrote:

>       What I am looking for is a query that will return a list of id's with a
> sum from table b and a sum from table c like this:
> 
>               id      name    sum(b)          sum(a)
>               1       shell    34              50
>               2       jeff     40              20
> 
> Thanks
> Jeff Meeks
> [EMAIL PROTECTED]

SELECT id, name,
       (SELECT sum(b) FROM b WHERE b.id=a.id) AS sum_b,
       (SELECT sum(c) FROM c WHERE c.id=a.id) AS sum_c
FROM   a;

-- 
Joel Burton   <[EMAIL PROTECTED]>
Director of Information Systems, Support Center of Washington


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to