pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: Re: join/group/count query.
Date: Thu, 21 Dec 2006 09:46:56 +0000
Message-ID: <200612210946.56643.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <8C5B026B51B6854CBE88121DBF097A866A4A9D@ehost010-33.exch010.intermedia.net>
References: <8C5B026B51B6854CBE88121DBF097A866A4A9D@ehost010-33.exch010.intermedia.net>

On Wednesday 20 December 2006 18:06, Hector Villarreal wrote:
> HI in reading this is it possible what was really intended :
> Sum(case when o_model = 5 then 1 else NULL end) as KA
> That would provide a count of all records meeting that condition.
> Otherwise the count( approach will not do that.
>

Because the else is NULL, count does work. Although I would imagine sum will 
also work, count more reflects the logic, i.e. the number of times that 
condition is true
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     



view thread (7+ messages)

Message-ID: <200612210946.56643.gary.stainburn@ringways.co.uk>
Permalink:  ../200612210946.56643.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200612210946.56643.gary.stainburn@ringways.co.uk

 · 

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: gary.stainburn@ringways.co.uk
  Subject: Re: join/group/count query.
  In-Reply-To: <200612210946.56643.gary.stainburn@ringways.co.uk>

* 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