Re: Weird join result

From: "Harald Armin Massa" <haraldarminmassa(at)gmail(dot)com>
To: "Peter Nixonn" <listuser(at)peternixon(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Weird join result
Date: 2006-08-16 14:35:24
Message-ID: 7be3f35d0608160735j562a68den31e584f149beb958@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Peter,

This returns 1280 rows, none of which are have a NULL value for sum. This
> surprised me at first as I thought the WHERE clause should apply before
> the
> OUTER JOIN but apparently not. I then tried the following:

what gives you the impression that WHERE clauses should be applied before
the JOINs ?
Clearly that is different. First joins, then where

propably you want sth like:

SELECT phones.CALLINGSTATIONID, sum(radacct.acctinputoctets)

FROM phones

> LEFT OUTER JOIN

(select * from raddact where radacct.ACCTSTARTTIME BETWEEN '2006-05-17
15:16:42' AND '2006-08-16 15:16:42' OR radacct.ACCTSTARTTIME ISNULL)
raddact
ON (phones.CALLINGSTATIONID =
radacct.CALLINGSTATIONID) WHERE
phones.CUSTID = 1

GROUP BY phones.CALLINGSTATIONID;

>
> best wishes Harald

--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607
-
Let's set so double the killer delete select all.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2006-08-16 14:59:17 Re: limitations of constraints, possible bugs
Previous Message Tom Lane 2006-08-16 14:31:34 Re: Segmentation Fault