convert row to column

From: NOVA <nova1427_at_gmail.com>
Date: Sat, 7 Mar 2009 05:53:23 -0800 (PST)
Message-ID: <f394153d-a98e-46ec-bdec-60a21ca73fc7_at_l39g2000yqn.googlegroups.com>



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 Received on Sat Mar 07 2009 - 07:53:23 CST

Original text of this message