Row aggregation in sqlite

Does anyone know if String Aggregation is possible in sqlite? If I have a column of animals with 5 lines / numbers, how can I combine them so that the output is in the same field as โ€œdogโ€, โ€œcatโ€, โ€œratโ€, โ€œmouseโ€, โ€œmouseโ€ as animals

thank

+11
source share
2 answers

You are looking for something like the following:

select group_concat(animal) from animals;

This will return something like the following:

dog,cat,rat,mice,mouse

If you do not want to use a comma as a separator, you can add your own separator as a second parameter:

select group_concat(animal, '_') from animals;

which will return:

dog_cat_rat_mice_mouse
+18
source

I think this will be useful:

group_concat(X)
group_concat(X,Y)

group_concat() , X. Y, X. (",") , Y . .

0

Source: https://habr.com/ru/post/1760372/


All Articles