Re: Joining more than 2 tables

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Joining more than 2 tables
Дата
Msg-id Pine.LNX.4.30.0104291012270.759-100000@peter.localdomain
обсуждение исходный текст
Ответ на Joining more than 2 tables  (Jeff Meeks <jmeekssr@net-serv.com>)
Список pgsql-general
Jeff Meeks writes:

>     I am trying to join 3 tables
> with this query
>     select a.id, a.name, sum(b.qty), sum(c.qty)
>     from a, b, c
>     where a.id=xxx and b.id=a.id and c.id=a.id
>
> what the sums that get returned look as if they are a cross products of
> the b and c tables.

It's hard to tell what you want to happen, but perhaps you want two
separate queries:

select a.id, a.name, sum(b.qty) from a, b where a.id=xxx and b.id=a.id
group by a.id, a.name;

and the same with 'c' in place of 'b'.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


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

Предыдущее
От: will trillich
Дата:
Сообщение: Re: Re: crypt(table.field) ?
Следующее
От: "Dr. Evil"
Дата:
Сообщение: Strange PG error