Group different rows in one by combining strings
I have a data set like this:
Column1 Column2
1 A
1 B
1 C
2 D
2 E
2 F
2 G
3 H
3 I
and I would like to merge it into something like this:
Column1 Column2
1 A, B, C
2 D, E, F, G
3 H, I
Is it possible to do this in SQLite somehow? I though of GROUP BY Column1, b开发者_Go百科ut I don't see how I can combine the Column2 data in one string...
Thanks!
SELECT Column1, group_concat(Column2) FROM Table GROUP BY Column1
group_concat takes an optional second argument (a string) to use as the concatenation separator if you don't want a single ',' character.
精彩评论