From: Graham Vickrage <graham@digitalplanit.com>
To: pgsql-sql@postgresql.org
Subject: Group by date_part
Date: Tue, 10 Jul 2001 20:04:55 +0100
Message-ID: <NDBBJABDILOPAOOMFJHOIEEJCMAA.graham@digitalplanit.com> (raw)
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);
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: graham@digitalplanit.com
Subject: Re: Group by date_part
In-Reply-To: <NDBBJABDILOPAOOMFJHOIEEJCMAA.graham@digitalplanit.com>
* 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