开发者

Group different rows in one by combining strings

开发者 https://www.devze.com 2023-01-20 01:04 出处:网络
I have a data set like this: Column1Column2 1A 1B 1C 2D 2E 2F 2G 3H 3I andI would like to merge it into something like this:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消