I'm, trying to write a query that will allow me to do the following:
"Find total number of open and closed tickets per day, within a specific date range".
Here's what I got so far
SELECT
COUNT(tikcet_id) as totalTickets,
COUNT(CASE WHEN ticket_status = 'Complete'
THEN 1
ELSE NULL END) as closedTickets,
DATE(ticket_date)
FROM tickets
WHERE (DATE(ticket_date) BETWEEN DATE('2014-07-18') AND DATE('2014-07-30'))
GROUP BY ticket_date
This is the results I'm getting, it counts the tickets fine, it just doesn't group them the way I want.
TotalTickets| ClosedTickets| ticket_date
1| 0| 2014-07-21 10:00:00
1| 0| 2014-07-21 10:21:21
0| 1| 2014-07-21 11:45:12
0| 1| 2014-07-22 09:21:24
0| 1| 2014-07-22 09:43:23
I would like to have them grouped by day, so for example I should be able to see something like that:
TotalTickets| ClosedTickets| ticket_date
2| 1| 2014-07-21
2| 0| 2014-07-22