Re: Weird join result - Mailing list pgsql-general

From Harald Armin Massa
Subject Re: Weird join result
Date
Msg-id 7be3f35d0608160735j562a68den31e584f149beb958@mail.gmail.com
Whole thread Raw
In response to Weird join result  (Peter Nixonn <listuser@peternixon.net>)
List 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.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Segmentation Fault
Next
From: "John R. Allgood"
Date:
Subject: Determine Transactions Per Second