我需要在concat
内group_concat
排序date
而我的查询精运行:MySQL:如何在group_concat中使用concat时进行排序?
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 ;
当我使用CONCAT然后才能通过努力站给出错误 – skhurams
'CONCAT'是一个函数,你不能在函数中使用子句(除了某些窗口函数)。你必须在CONCAT()函数的OUTSIDE外面进行排序。此外,在GROUP_CONCAT中不能有多个'ORDER BY'子句。 – Pred