Help with a query for charting

From: Andrew Veitch <andrew(dot)veitch(at)blueyonder(dot)co(dot)uk>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Help with a query for charting
Date: 2003-01-31 17:55:49
Message-ID: BA606925.884E%andrew.veitch@blueyonder.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Larry Rosenman 2003-01-31 18:14:54 Re: Postgres MD5 Function
Previous Message Wei Weng 2003-01-31 16:43:14 Which version is this?