Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 21 Sep 2006 @ 12:49:59 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Column To Row Conversion
 
From:   Anomy Anom

<-- Anonymously Posted: Thursday, September 21, 2006 06:33 -->

I have a table as follows

     col1      col2      col3
     ------------------------
     1         NULL      20
     NULL      3         NULL
     NULL      NULL      30

I want result as

     Result
     ------
     1
     20
     3
     30

I can write query as

     select
         col1
     FROM table1
     WHERE
         col1 IS NOT NULL

     UNION ALL
     select
         col2
     FROM table1
     WHERE
         col2 IS NOT NULL

     UNION ALL
     select
         col3
     FROM table1
     WHERE
         Col3 IS NOT NULL

Would like to know is there any better approach than this, with out needing to query the table again again.

Note: Above is the much simplified version. The table which we are referring to has 50 columns and has millions of rows.


Thanks in advance.



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023