From: Andrew Veitch <andrew.veitch@blueyonder.co.uk>
To: pgsql-sql@postgresql.org
Subject: Help with a query for charting
Date: Fri, 31 Jan 2003 17:55:49 +0000
Message-ID: <BA606925.884E%andrew.veitch@blueyonder.co.uk> (raw)
I'm trying to do a query to count the number of tickets opened on each day
of a month. It'll always be from the 1st to the end of the month. This does
it:
SELECT TO_CHAR(DATE_TRUNC('day',date_opened),'DD') AS day, COUNT(*)
FROM ticket GROUP BY DATE_TRUNC('day', date_opened)
WHERE <date range here>;
But it doesn't give me a zero for the days when no tickets were opened -
which I really need because I want to graph the result.
I could do this in the application code but that doesn't seem right.
Help would be great.
Andrew
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: andrew.veitch@blueyonder.co.uk
Subject: Re: Help with a query for charting
In-Reply-To: <BA606925.884E%andrew.veitch@blueyonder.co.uk>
* 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