convert column data into a single row

Database

convert column data into a single row

My table:

col1 | col2 | col3

a,1,6

b,2,7

c,3,8

d,4,9

e,5,10

 

Output should be:

a,b,c,d,e

1,2,3,4,5

6,7,8,9,10

 

Please help.

 

Thanks

 

1 REPLY
Enthusiast

Re: convert column data into a single row

Hi,

 

You can use xmlagg funtion to do this if you have XML serivices available like this :

 

SELECT
TRIM(TRAILING ',' FROM (XMLAGG(test_dt || ','
ORDER BY test_dt
) (VARCHAR(10000))))
FROM test

--Samir