By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH mytable AS (
SELECT 1 id, 'x' a, 'y' b, 'r' c
UNION ALL SELECT 2, 'x', 'y', 'q'
UNION ALL SELECT 3, 'x', 'y', 'f'
)
SELECT a, b, GROUP_CONCAT(c ORDER BY id) c
FROM mytable
GROUP BY a, b
ORDER BY a, b
a | b | c |
---|---|---|
x | y | r,q,f |