pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Carol Cheung <cacheung@consumercontact.com>
To: pgsql-sql@postgresql.org
Subject: Re: left outer join on more than 2 tables?
Date: Wed, 17 Jun 2009 09:07:23 -0400
Message-ID: <4A38EA8B.5000403@consumercontact.com> (raw)
In-Reply-To: <4A3826FB.8090907@gmail.com>
References: <4A3807CF.90109@consumercontact.com>
	<396486430906161425i1cb7949enff5443cc2043805a@mail.gmail.com>
	<4A38114B.7090106@gmail.com>
	<396486430906161550v30befebelcfddd58ebc4b4f2d@mail.gmail.com>
	<4A3826FB.8090907@gmail.com>


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@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).
> 

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



view thread (8+ messages)

Message-ID: <4A38EA8B.5000403@consumercontact.com>
Permalink:  ../4A38EA8B.5000403@consumercontact.com/
Also on:    postgresql.org/message-id/4A38EA8B.5000403@consumercontact.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cacheung@consumercontact.com
  Subject: Re: left outer join on more than 2 tables?
  In-Reply-To: <4A38EA8B.5000403@consumercontact.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox