If you do this in two steps. Make your entries id(n) = x and then GROUP_CONCAT ().
SELECT GROUP_CONCAT(id_count SEPARATOR ', ') FROM (SELECT CONCAT('id(', id, ') = ', count(type)) id_count FROM T GROUP BY id) data
But note that this is often a sign of SQL Anti-Pattern.
It is generally recommended not to compress multiple values ββinto a single value. And it is usually recommended to maintain separation of view and data.
source share