Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 15 Aug 2005 @ 18:10:50 GMT


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


Subj:   Re: How to Substring data
 
From:   sanjaya.nagabhushan

Partho,

Try this...

     sel
     substr((substr((trim(leading '-' from i)), index((trim(leading '-' from i)), '-')+1)), 1,
            ((
     case when (index ((substr((trim(leading '-' from i)),
     index((trim(leading '-' from i)), '-')+1)), '-')) = 0 then 1
          else index ((substr((trim(leading '-' from i)), index((trim(leading
     '-' from i)), '-')+1)), '-')
     end)-1)) as res3
     from abc;

If that query is not clear then you can create these two views & use this query...

     create view v1 as sel trim(leading '-' from i) as i1 from abc;

     create view v2 as sel substr(i1, index(i1, '-')+1) as i2 from v1;

     sel substr(i2, 1, ((case when index(i2, '-')=0 then 1 else index(i2,
     '-') end)-1)) from v2;

Regards,

Sanjaya



     
  <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