Converting Rows Into Columns Using DECODE
916986Feb 16 2012 — edited Feb 17 2012Hi All,
I am facing some problems while converting the rows into columns. I am using Oracle 10g....
My table structure is given below:-
SQL> select * from t;
ID VALUE
---------- -----------
1 X
1 Y
1 Z
2 A
2 B
2 C
6 rows selected.
My desired output is:-
ID Value
1 X,Y,Z
2 A,B,C
I have tried to achieve this using the below query and I am able to get it..
select id,rtrim (xmlagg (xmlelement (e, value || ',')).extract ('//text()'), ',') from t5 group by id;
What are the different ways to achieve this. Can the same thing be achieved using DECODE.
Please let me know what are the other ways to do it.
Thanks & Regards,
Arijit