I want to extract number from String

Analytics
Fan

I want to extract number from String

Suppose I have string like

RD_S0310
RD_153
RDH_S0906
RD_S0083

I want output

0310
153
0906
0083

How can I do this
2 REPLIES
Teradata Employee

Re: I want to extract number from String

Simple way assuming all numbers are preceded by _ or _s:

select case when substr(col_1, index(col_1 '_') +1, character_length(col_1)) from mytable
union
select case when substr(col_1, index(col_1 '_s') +1, character_length(col_1)) from mytable
;

other wise you should use recursive sql.
Enthusiast

Re: I want to extract number from String

 how to Return digits or alphas from a string 

for example:123ab45cde6789fg