All Forums Database
kamu2015 2 posts Joined 08/15
28 Aug 2015
TRIM Leading letters then Leading 0

I have a column that always has 12 characters.  The values can vary with how many leading letters and zeros they have.  
Example list:
A00294759323
HA2947037493
A29403829574
194093829593
D00284938293
000294869302
Desired output:
294759323
2947037493
29403829574
194093829593
284938293
294869302
 
Is there a way to TRIM LEADING '0' OR 'A' OR 'B' OR 'C' etc.?

dnoeth 4628 posts Joined 11/04
29 Aug 2015

The easiest way to get what you want is probably a regular expression, find the first digit which is not a zero:

regexp_substr(col, '([1-9].*)')

 

Dieter

kamu2015 2 posts Joined 08/15
31 Aug 2015

Perfect. Thank you!

You must sign in to leave a comment.