This query will give you the previous months tickets opened by category.
SELECT
COUNT(HD_TICKET.ID) AS NUMBER_TICKETS,
HD_CATEGORY.NAME AS CATEGORY,
date_format(HD_TICKET.CREATED, '%M %Y') AS DATE_CREATED
FROM
HD_TICKET
JOIN
HD_CATEGORY ON (HD_CATEGORY.ID = HD_TICKET.HD_CATEGORY_ID)
WHERE
(HD_TICKET.HD_QUEUE_ID = 1)
AND (TIMESTAMP(HD_TICKET.CREATED) BETWEEN date_format(NOW() - INTERVAL 1 MONTH, '%Y-%m-01')
AND last_day(NOW() - INTERVAL 1 MONTH))
GROUP BY DATE_CREATED , CATEGORY
The results look like this.
Comments