【发布时间】:2019-03-13 09:32:42
【问题描述】:
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
上面的代码正确返回除了第一行之外的所有行。 chartData中的第一组数据是反的
In the first row, the 20 should be after the 58
提前谢谢你!
【问题讨论】:
-
你的意思是
GROUP_CONCAT(sum ORDER BY 'date' DESC) AS chartData? -
@Zack 不管我在代码中怎么加 DESC 或 ASC,
chartData第一行的结果是相反的
标签: mysql sql group-concat