| From: | Joel Burton <jburton(at)scw(dot)org> |
|---|---|
| To: | Jeff Meeks <jmeekssr(at)net-serv(dot)com> |
| Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
| Subject: | RE: Joining more than 2 tables |
| Date: | 2001-05-02 17:43:03 |
| Message-ID: | Pine.LNX.4.21.0105021341580.17067-100000@olympus.scw.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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
> jmeekssr(at)net-serv(dot)com
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 <jburton(at)scw(dot)org>
Director of Information Systems, Support Center of Washington
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ryan Mahoney | 2001-05-02 19:07:04 | Re: Ideal hardware configuration for pgsql |
| Previous Message | Peter Eisentraut | 2001-05-02 17:30:13 | Re: Improve a query... |