Re: left outer join on more than 2 tables? - Mailing list pgsql-sql

From Rob Sargent
Subject Re: left outer join on more than 2 tables?
Date
Msg-id 4A3826FB.8090907@gmail.com
Whole thread Raw
In response to Re: left outer join on more than 2 tables?  (Richard Broersma <richard.broersma@gmail.com>)
Responses Re: left outer join on more than 2 tables?  (Carol Cheung <cacheung@consumercontact.com>)
List pgsql-sql
Richard Broersma wrote:
> On Tue, Jun 16, 2009 at 2:40 PM, Rob Sargent<robjsargent@gmail.com> wrote:
>
>   
>> Is there a city without a reference to region?
>>     
>
> I don't know, but the OP wanted to know complaints by region.
>
>   
I didn't try this, but with regionless cities, you may need a full join
if you want a complete accounting of all complaints, some being logged
to the null region.


>
>
>   
>>  And wouldn't you want to count(cm.id)?
>>     
>
> Count(cm.id) and Count(*) produce the same result.  But I like
> Count(*) more since it helps to correctly express the idea that we are
> counting rows per group and not cm.id(s) per group.
>
>
>
>   

"Same result" is not true.  I loaded tables. 

Using count(*) you get count=1 for regions without complaints.  Using 
count(complaint.id) you get count = 0.  (The deference amount to 
counting the left hand side (region) vs the right hand side (complaint) 
which I believe is what OP is after).




pgsql-sql by date:

Previous
From: Richard Broersma
Date:
Subject: Re: left outer join on more than 2 tables? (UNCLASSIFIED)
Next
From: Carol Cheung
Date:
Subject: Re: left outer join on more than 2 tables?