Search Postgresql Archives

Re: Weird join result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux