Para obter a saída desejada, você deve examinar
GROUP_CONCAT()
:SELECT
id, month,
GROUP_CONCAT(col) AS col,
GROUP_CONCAT(col2) AS col2
FROM
your_table
GROUP BY
id, month;
GROUP_CONCAT()
:SELECT
id, month,
GROUP_CONCAT(col) AS col,
GROUP_CONCAT(col2) AS col2
FROM
your_table
GROUP BY
id, month;