I have two columns X and Y where the values could be as below:
X Y
--------------
rob one.1
rob two.2
rob abc.3
rob pqr.4
harry lmn.3
harry lkja.4
harry lkjs.6
I am querying on column X. That is
select Y where X='rob'
select Y where X='harry'
I want to write a query on above columns where the output will be strings like “rob # 1,2,3,4” and “harry # 3,4,6”
So first part of the result string will be the X value followed by a constant # followed by the numbers in Y after ‘.’ dot.
So rob gets 1,2,3,4 and harry has 3,4,6
Thanks for reading
I achieved it using aggregate functions in db2: