Re: simple LEFT JOIN giving wrong results ...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: simple LEFT JOIN giving wrong results ...
Дата
Msg-id 15860.1071180972@sss.pgh.pa.us
обсуждение исходный текст
Ответ на simple LEFT JOIN giving wrong results ...  ("Marc G. Fournier" <scrappy@hub.org>)
Ответы Re: simple LEFT JOIN giving wrong results ...  ("Marc G. Fournier" <scrappy@postgresql.org>)
Список pgsql-sql
"Marc G. Fournier" <scrappy@hub.org> writes:
> So, I'm doing my LEFT JOIN wrong *somehow*, but its eluding me as to
> what/how .. :(

> ams=# select ct.ip_id, sum(ct.bytes) as traffic,
>              avg(cs.bytes)::bigint as storage
>         from company_00186.traffic ct
>    left join company_00186.storage cs ON ( ct.ip_id = cs.ip_id AND
>                                            month_trunc(cs.runtime) = '2003-12-01')
>        where month_trunc(ct.runtime) = '2003-12-01' group by ct.ip_id;

I suspect you do not want the month_trunc constraint to be included
in the JOIN ON condition, only in WHERE.
        regards, tom lane


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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: simple LEFT JOIN giving wrong results ...
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: simple LEFT JOIN giving wrong results ...