Disculpen alguien tiene idea de como ordenar el total de menor a mayor utilizando su alias o con un AND, cuando lo agrego en GROUP BY total no me obtiene ningún resultado, alguien podria ayudarme.
este es mi consulta actual.
SELECT DATE_FORMAT(calendar.datefield, '%W %d %M %Y') AS fecha,
IFNULL (COUNT(t.id),0) AS total,
EXTRACT(MONTH FROM calendar.datefield) AS mes
FROM wpam_psmsc_tickets t
RIGHT JOIN calendar ON (DATE(t.date_created) = calendar.datefield)
WHERE (calendar.datefield BETWEEN (SELECT MIN(DATE(date_created)) FROM wpam_psmsc_tickets)
AND (SELECT MAX(DATE(date_created)) FROM wpam_psmsc_tickets))
AND month(calendar.datefield) = 12 AND year(calendar.datefield) = 2022
GROUP BY fecha DESC LIMIT 10
y me devuelve esto pero yo quiero ordenarlo por el total
fecha | total | mes |
---|---|---|
Wednesday 28 December 2022 | 2 | 12 |
Wednesday 21 December 2022 | 0 | 12 |
Wednesday 14 December 2022 | 7 | 12 |
Wednesday 07 December 2022 | 3 | 12 |
Tuesday 27 December 2022 | 1 | 12 |
Tuesday 20 December 2022 | 3 | 12 |
Tuesday 13 December 2022 | 5 | 12 |
Tuesday 06 December 2022 | 5 | 12 |
Thursday 29 December 2022 | 2 | 12 |
Thursday 22 December 2022 | 3 | 12 |