pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roberto Mello <rmello@cc.usu.edu>
To: Graham Vickrage <graham@digitalplanit.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Group by date_part
Date: Tue, 10 Jul 2001 13:36:23 -0600
Message-ID: <20010710133623.A27302@cc.usu.edu> (raw)
In-Reply-To: <NDBBJABDILOPAOOMFJHOIEEJCMAA.graham@digitalplanit.com>
References: <NDBBJABDILOPAOOMFJHOIEEJCMAA.graham@digitalplanit.com>

On Tue, Jul 10, 2001 at 08:04:55PM +0100, Graham Vickrage wrote:
> 
> The statement I have only selects the count if there is at least 1 order for
> a particular day, which make sense.
> 
> I however need a count of 0 for days that don't have any. Can anyone help?
> 
> SQL:
> 
> SELECT date_part('day', date), count(*)
> FROM client_order WHERE (date >= '01/05/01' AND date < '01/06/01') AND
> status = 'Processing'
> GROUP BY date_part('day', date);

	Didn't look very hard, but can't you just add a: 

CASE WHEN count(*) > 0 THEN count(*) ELSE 0 END AS count

	-Roberto
-- 
+----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net 
       http://www.sdl.usu.edu - Space Dynamics Lab, Developer    
HELP! My hard drive crashed & I can't boot up!



view thread (6+ messages)  latest in thread

Message-ID: <20010710133623.A27302@cc.usu.edu>
Permalink:  ../20010710133623.A27302@cc.usu.edu/
Also on:    postgresql.org/message-id/20010710133623.A27302@cc.usu.edu

 · 

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: rmello@cc.usu.edu, graham@digitalplanit.com
  Subject: Re: Group by date_part
  In-Reply-To: <20010710133623.A27302@cc.usu.edu>

* 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