From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc G. Fournier <scrappy@hub.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: simple LEFT JOIN giving wrong results ...
Date: Thu, 11 Dec 2003 17:16:12 -0500
Message-ID: <15860.1071180972@sss.pgh.pa.us> (raw)
In-Reply-To: <20031211165902.I17041@ganymede.hub.org>
References: <20031211165902.I17041@ganymede.hub.org>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, scrappy@hub.org
Subject: Re: simple LEFT JOIN giving wrong results ...
In-Reply-To: <15860.1071180972@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox