Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Sun, 03 Jun 2007 @ 21:36:29 GMT


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


Subj:   Re: Extracting First,Middle and last Name
 
From:   Jinesh P V

     sel  substr(FullName,1,FirstOccurance -1 ) as Firstname,
          case when SecondOccurance > 0
                    then substr(Extract2, 1, SecondOccurance -1 )
               else  ''
          end as MiddleName,
          case when SecondOccurance > 0
                    then Extract3
               else substr(Extract2, 1, SecondOccurance -1 )
          end as LastName

     from
     (
             sel
             trim('hello            world            program') as FullName,
             position( ' '  in FullName) as FirstOccurance,
             trim(substr(FullName,FirstOccurance + 1)) as  Extract2,
             position(' ' in Extract2 ) as SecondOccurance,
             trim(substr(Extract2 ,SecondOccurance + 1)) as  Extract3
     )tmp

thanks,

Jinesh P V



     
  <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