Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 21 Sep 2007 @ 18:01:20 GMT


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


Subj:   Re: Name Format Change
 
From:   Anomy Anom

<-- Anonymously Posted: Friday, September 21, 2007 13:34 -->

Here is an example of "last, first middle (if any)" in output, as you described in your example.

     create volatile table nametable
     (c1 VARCHAR(42))
     primary index (c1) on commit preserve rows;
     insert into nametable sel 'Scott S Smith';
     insert into nametable sel 'Mike K. Carter';
     insert into nametable sel 'Sam Simpson';
     SELECT CASE
     WHEN INDEX(SUBSTR(c1, INDEX(c1, ' ')+1, CHAR(c1)),' ') <= 0 THEN
     SUBSTR(c1, INDEX(c1, ' ')+1, CHAR(c1)) || ', ' || SUBSTR(c1,0,INDEX(c1, ' '))
     ELSE
     SUBSTR(c1, INDEX(SUBSTR(c1, INDEX(c1, ' ')+1, CHAR(c1)),' ')+INDEX(c1,'
     ')+1,CHAR(c1)) ||', ' ||
     SUBSTR(c1, 0, INDEX(c1, ' ')+INDEX(SUBSTR(c1, INDEX(c1, ' ')+1,
     CHAR(c1)),' ') )
     END
     FROM NAMETABLE;

Output:

     < CASE  expression >
     Smith, Scott S
     Simpson, Sam
     Carter, Mike K.


     
  <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