答案 0 :(得分:0)
请尝试以下查询:
SELECT
`date`,
TRIM(BOTH ',' FROM (GROUP_CONCAT(CASE WHEN unit='Unit-1' THEN amount ELSE '' END),',','') AS `Unit-1`,
TRIM(BOTH ',' FROM (GROUP_CONCAT(CASE WHEN unit='Unit-2' THEN amount ELSE '' END),',','') AS `Unit-2`
FROM myTable GROUP BY `date`;
这是你想要的图像中显示的记录吗?