-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
> 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.
> ...
> But it doesn't give me a zero for the days when no tickets were opened
The problem is that S
you could keep a table with list of all possible days in a month.
left join that to the results you get from query below this will return NULL
for days where there is no data. NULL could then easily converted to 0 using CASE
or COALESCE.
regds
mallah.
> I'm trying to do a query to count the n
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 ;
But it