sql - Select multiple rows into a single row -


i have table columns "sequence-id", "event-id", "value"

to 1 sequence belongs 5 events , each event has 1 value e.g.:

|sequence-id | event-id | value | |------------|----------|-------| |1           |         1|      7| |1           |         2|      2| |1           |         3|      5| |1           |         4|      9| |1           |         5|     12| |2           |         1|     15| |2           |         2|      8| |2           |         3|     10| |2           |         4|     21| |2           |         5|     17| 

how can select each sequence 1 row, separated semicolon?

|sequence-id |value        | |------------|-------------| |1           |7;2;5;9;12   | |2           |15;8;10;21;17| 

use string_agg(col1)

   select sequence-id , string_agg(value , ';')  newvalue     table     group  sequence-id; 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -