Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 77955633954 for ; Tue, 16 Jun 2009 20:12:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 97334-07 for ; Tue, 16 Jun 2009 20:12:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.183]) by mail.postgresql.org (Postfix) with ESMTP id B0845633318 for ; Tue, 16 Jun 2009 20:12:48 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id m16so1012279waf.19 for ; Tue, 16 Jun 2009 16:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=cAHfC22WIxfBmSybEmN6f1I7B+ovgfTaNAKg4BXaiRg=; b=AQ8fVAdZqDzDnrRYzwu1UESadSIWNJrKcCIfgPiS4JSOBbCKm/3w433sZKn18CPAzU z1eJrUPQWiFOkRBN4N5jYjSQVyr0CG8B/vizyPOFB8DY9as0kYTBidEChegIYsrg8Asm jzrlVoQ3ophsu7ZSdeH4Avc4kW24joy7dZMLk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=BsJWUGttCWZo9QcFSJuZKL+Hz4FM/QpnyP9gdDySdtQsBqSXzCM/apyi/9ZW7SqvY6 XVsV4JkxTBkQqkVxwMhQT/wDCqPhXb1Xt/MA38ymmkUAw9znqHrrOhVgQhbRnciXZXts frS6agoltLQW3ulT6CiRz4dLHDWtZFZqsKjCs= Received: by 10.114.199.1 with SMTP id w1mr14506106waf.151.1245193967057; Tue, 16 Jun 2009 16:12:47 -0700 (PDT) Received: from ?172.16.1.32? ([208.187.158.94]) by mx.google.com with ESMTPS id m28sm1278895waf.37.2009.06.16.16.12.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 16 Jun 2009 16:12:46 -0700 (PDT) Message-ID: <4A3826FB.8090907@gmail.com> Date: Tue, 16 Jun 2009 17:12:59 -0600 From: Rob Sargent User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Richard Broersma , pgsql-sql@postgresql.org Subject: Re: left outer join on more than 2 tables? References: <4A3807CF.90109@consumercontact.com> <396486430906161425i1cb7949enff5443cc2043805a@mail.gmail.com> <4A38114B.7090106@gmail.com> <396486430906161550v30befebelcfddd58ebc4b4f2d@mail.gmail.com> In-Reply-To: <396486430906161550v30befebelcfddd58ebc4b4f2d@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200906/82 X-Sequence-Number: 32687 Richard Broersma wrote: > On Tue, Jun 16, 2009 at 2:40 PM, Rob Sargent 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).