| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Interesting data transposition problem
Hi,
I am handling a complex query and ultimately the problem boils down to
this.
I have the data in the format
Col1 Col2 X a X b Y c Y d Y e
but I need this data in the following format (note that the column names have changed to the data)
X Y
a c
b d
e
I have managed to get
X Y
c
d
e
but can't get what I want. I am using the following query -
select decode(col1,'X',col2) as x,
decode(col1,'Y',col2) as y
from
(
select 'X' as col1, 'a' as col2 from dual
union all
select 'X' as col1, 'b' as col2 from dual
union all
select 'Y' as col1, 'c' as col2 from dual
union all
select 'Y' as col1, 'd' as col2 from dual
union all
select 'Y' as col1, 'e' as col2 from dual
)
Can anyone please help?
Thanks.
Puneet
Received on Thu Jun 09 2005 - 17:25:23 CDT
![]() |
![]() |