我需要在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