Re: Left Outer Join Question

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Edward Murray" <mail(at)avenuedesign(dot)net>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Left Outer Join Question
Date: 2002-02-27 05:23:56
Message-ID: GNELIHDDFBOCMGBFGEFOCEJCCBAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> select category.name, count(items.recordnum) from category left outer join
> items on (category.recordnum = items.catnum) where category.recordnum =
> section_subcats.catnum and section_subcats.sectionnum = 1 and
> items.clientnum = 333 group by category.name;

Try using:

count(coalesce(items.recordnum, 0))

instead of:

count(items.recordnum)

I can't guarantee that it will work - I haven't tried it myself. What's
probably happening is that count isn't counting NULLs?

Chris

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-02-27 05:48:04 Re: Timestamp output
Previous Message OV 2002-02-27 04:52:49 Re: Removing duplicates