How can I "merge", "flatten" or "pivot" results from a query which returns multiple rows into a sing
- by dsm
I have a simple query over a table, which returns results like the following:
id id_type id_ref
2702 5 31
2702 16 14
2702 17 3
2702 40 1
2702 26 4
And I would like to merge the results into a single row, for instance:
id concatenation
2702 5,16,17,40,26:31,14,3,1,4
Is there any way to do this within a trigger?
NB: I know I can use a cursor, but I would really prefer not to unless there is no better way.