Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 14 Oct 2015 @ 09:16:06 GMT


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


Subj:   Re: Unique String sequence
 
From:   Angela.O.Wong

Not sure exactly if this is what you want to see for the result:

     select
      '111122244411' as ID
     ,substr(ID,1,1) ||
      case when substr(ID,2,1) <> substr(ID,1,1) then substr(ID,2,1) else '' end
     ||
      case when substr(ID,3,1) <> substr(ID,2,1) then substr(ID,3,1) else '' end
     ||
      case when substr(ID,4,1) <> substr(ID,3,1) then substr(ID,4,1) else '' end
     ||
      case when substr(ID,5,1) <> substr(ID,4,1) then substr(ID,5,1) else '' end
     ||
      case when substr(ID,6,1) <> substr(ID,5,1) then substr(ID,6,1) else '' end
     ||
      case when substr(ID,7,1) <> substr(ID,6,1) then substr(ID,7,1) else '' end
     ||
      case when substr(ID,8,1) <> substr(ID,7,1) then substr(ID,8,1) else '' end
     ||
      case when substr(ID,9,1) <> substr(ID,8,1) then substr(ID,9,1) else '' end
     ||
      case when substr(ID,10,1) <> substr(ID,9,1) then substr(ID,10,1) else ''
     end ||
      case when substr(ID,11,1) <> substr(ID,10,1) then substr(ID,11,1) else ''
     end ||
      case when substr(ID,12,1) <> substr(ID,11,1) then substr(ID,12,1) else ''
     end
      as new_ID


     
  <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: 23 Jun 2019