SELECT item_description, item_variant, branch, GROUP_CONCAT(sum ORDER BY 'date') AS chartData
FROM (
SELECT item_description, item_variant, branch, SUM(sales) AS sum
FROM inventory_branches
WHERE (item_description = 'agapanthus') AND (date BETWEEN '2018-06' AND '2018-08')
GROUP BY item_description, item_variant, branch, MONTH(date) DESC
) T
GROUP BY item_description, item_variant, branch, MONTH('date')
LIMIT 5
The code above returns all rows correctly except for the first one. The first group of data in chartData
is in reverse
In the first row, the 20 should be after the 58
Thank you in advance!