3
Good morning! I’m having some difficulty making one SELECT
selecting data from the last 365 days (12 months).
What I want you to show is: in the last 12 months you have to show (per month) a number (in this case the sum of id
created that same month).
I think the mistake is in this part of the code:
BETWEEN now() AND DATE_ADD(now(), INTERVAL -12 MONTH)
But I’m not sure because Workbench no errors! Just shows nothing!
My code is this::
SELECT COUNT(id) AS id, DATE_FORMAT(create_time, '%m-%Y') AS data_mes
FROM ticket
WHERE ticket_state_id = 2 AND create_time BETWEEN now() AND DATE_ADD(now(), INTERVAL -12 MONTH)
GROUP BY MONTH(create_time);
Do not put resolved in the question title, which is not the way the site works. You indicate if the question has been resolved by accepting an answer by clicking on the green mark next to it
– Isac
I appreciate the information! Since I am still recent on the site. So I can only accept my own answer in 2 days.
– João Simões