Skip site navigation (1) Skip section navigation (2)

Re: join/group/count query.

From: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: join/group/count query.
Date: 2006-12-21 09:46:56
Message-ID: 200612210946.56643.gary.stainburn@ringways.co.uk (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-sql
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     

In response to

pgsql-sql by date

Next:From: Alexis Paul BertoliniDate: 2006-12-22 23:12:16
Subject: Changing character set when the damage is done
Previous:From: Sandip GDate: 2006-12-21 07:41:33
Subject: NEED URGENT HELP....

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group