convert row top column -
03-07-2009
, 07:40 AM
Dear all,
I have this table as as example
select 'A' C1, 5 C2 from dual union all
select 'B', 8 from dual union all
select 'C', 2 from dual union all
select 'D', 9 from dual
the query below make the rows as column, I want another way to make it
by good performance becase if I applay the query on alot of rows it
will take long of time.
SELECT
MAX(CASE WHEN C1='A' THEN C2 END) A,
MAX(CASE WHEN C1='B' THEN C2 END) B,
MAX(CASE WHEN C1='C' THEN C2 END) C,
MAX(CASE WHEN C1='D' THEN C2 END) D
FROM
(
select 'A' C1, 5 C2 from dual union all
select 'B', 8 from dual union all
select 'C', 2 from dual union all
select 'D', 9 from dual
)
there is another way?
thx
Best Regards; |