Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 14 Jul 2004 @ 17:06:45 GMT


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


Subj:   Re: Changing a column name while concatinating
 
From:   Anomy Anom

<-- Anonymously Posted: Wednesday, July 14, 2004 11:48 -->

I had to do something similar to parse complex strings pre-UDF. The only solution I came up with is to alias the case expressions as columns in a derived table:

     SELECT  FinalCol
     FROM            (
             SELECT  CASE WHEN  THEN  ELSE '' END NewCol1
             ,       CASE WHEN  THEN  ELSE ''
     END || NewCol1 NewCol2
             ,       CASE WHEN  THEN  ELSE ''
     END || NewCol2 NewCol3
             ...
             ,       NewColN || 'bar' FinalCol
             )
     ;

or

     SELECT  NewCol1 || NewCol2 || NewCol3 || .... || NewColN || 'bar'
     FinalCol
     FROM            (
             SELECT  CASE WHEN  THEN  ELSE '' END NewCol1
             ,       CASE WHEN  THEN  ELSE ''
     END NewCol2
             ,       CASE WHEN  THEN  ELSE ''
     END NewCol3
             ...
             ,       'bar' FinalCol
             )
;


     
  <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