Group by date_part

From: "Graham Vickrage" <graham(at)digitalplanit(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Group by date_part
Date: 2001-07-10 19:04:55
Message-ID: NDBBJABDILOPAOOMFJHOIEEJCMAA.graham@digitalplanit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I need to select the amount of orders per day from an order table.

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);

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andre Schnabel 2001-07-10 19:35:56 Re: Problems with PG_DUMP and restore
Previous Message Josh Berkus 2001-07-10 18:50:07 Re: Problems with PG_DUMP and restore