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

From Richard Broersma
Subject Re: left outer join on more than 2 tables?
Date
Msg-id 396486430906161425i1cb7949enff5443cc2043805a@mail.gmail.com
Whole thread Raw
In response to left outer join on more than 2 tables?  (Carol Cheung <cacheung@consumercontact.com>)
Responses Re: left outer join on more than 2 tables?  (Rob Sargent <robjsargent@gmail.com>)
Re: left outer join on more than 2 tables?  (Gavin Baumanis <gavinb@eclinic.com.au>)
List pgsql-sql
On Tue, Jun 16, 2009 at 1:59 PM, Carol
Cheung<cacheung@consumercontact.com> wrote:
> I would like to find the counts of complaints by region and I would like all
> regions to be displayed, regardless of whether or not complaints exist for
> that region. Is left outer join what I'm looking for?
  SELECT R.region_name, Count(*) AS RegionComplaints    FROM Region AS R
LEFT JOIN City AS Ci      ON R.id = C.region_id
LEFT JOIN Complaint AS Cm      ON Ci.id = Cm.city_idGROUP BY R.region_name;


-- 
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug


pgsql-sql by date:

Previous
From: Carol Cheung
Date:
Subject: left outer join on more than 2 tables?
Next
From: "Hall, Crystal M CTR DISA JITC"
Date:
Subject: Re: left outer join on more than 2 tables? (UNCLASSIFIED)