convert row top column

From: NOVA <nova1427_at_gmail.com>
Date: Sat, 7 Mar 2009 05:40:48 -0800 (PST)
Message-ID: <c4246b97-587b-469e-abac-565eee7a5d24_at_a39g2000yqc.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:40:48 CST

Original text of this message