当我的查询运行正常时,我需要在 group_concat
中的 concat
中对 date
进行排序:
SELECT
report.`Name`,
GROUP_CONCAT(
CONCAT(
"[",
DATE(report.Date) --(not working) order by DATE(report.Date) ,
',',
report.ProductPrice --(not working) order by DATE(report.ProductPrice) ,
"]"
)
) AS ProductPrice
FROM report
GROUP BY report.Name ;
最佳答案
你应该在 group_concat
中使用它,而不是 concat
:
group_concat(
concat('[', date(report.Date), ',', report.ProductPrice, ']')
order by date(report.Date) desc
)
关于MySQL:在group_concat中使用concat时如何排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37941939/