Re: left outer join on more than 2 tables?

From: Carol Cheung <cacheung(at)consumercontact(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: left outer join on more than 2 tables?
Date: 2009-06-17 13:07:23
Message-ID: 4A38EA8B.5000403@consumercontact.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On 16/06/2009 19:12, Rob Sargent wrote the following:
> Richard Broersma wrote:
>> On Tue, Jun 16, 2009 at 2:40 PM, Rob Sargent<robjsargent(at)gmail(dot)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).
>

Thanks everyone for your help. Your solutions worked. Much appreciated.
- Carol

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Hall, Crystal M CTR DISA JITC 2009-06-17 15:06:19 Re: left outer join on more than 2 tables? (UNCLASSIFIED)
Previous Message Rob Sargent 2009-06-16 23:12:59 Re: left outer join on more than 2 tables?