dbTalk Databases Forums  

convert row top column

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss convert row top column in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
NOVA
 
Posts: n/a

Default 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;

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.