Re: Group by date_part - Mailing list pgsql-sql

From Roberto Mello
Subject Re: Group by date_part
Date
Msg-id 20010710133623.A27302@cc.usu.edu
Whole thread Raw
In response to Group by date_part  ("Graham Vickrage" <graham@digitalplanit.com>)
List pgsql-sql
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!


pgsql-sql by date:

Previous
From: A_Schnabel@t-online.de (Andre Schnabel)
Date:
Subject: Re: Problems with PG_DUMP and restore
Next
From: Kristis Makris
Date:
Subject: ERROR: Procedures cannot take more than 16 arguments