RE: Joining more than 2 tables

Поиск
Список
Период
Сортировка
От Joel Burton
Тема RE: Joining more than 2 tables
Дата
Msg-id Pine.LNX.4.21.0105021341580.17067-100000@olympus.scw.org
обсуждение исходный текст
Ответ на RE: Joining more than 2 tables  (Jeff Meeks <jmeekssr@net-serv.com>)
Список 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@net-serv.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@scw.org>
Director of Information Systems, Support Center of Washington


В списке pgsql-general по дате отправления:

Предыдущее
От: Doug McNaught
Дата:
Сообщение: Re: Re: Stranger than fiction - EXPLAIN results
Следующее
От: "Gregory Wood"
Дата:
Сообщение: Re: Stranger than fiction...