How to extract a group of numbers

Hello,

Is there a way to return a group of 8 numbers and strip the rest away? Initially I was using SELECT   SUBSTR(c.afenumber, -8) to return the last 8 characters which are preceded by other text, but that doesn't help address data where the number preceeds the text. Here are some examples of what the data looks like:

10187413-2001
DH01-10193383
10215916-NALN
10204022 - Reco

Any suggestions?


mskittenAsked:
Who is Participating?
 
mskittenConnect With a Mentor Author Commented:
If all the numbers I need start with '10', this might be all I need:

SELECT   SUBSTR(c.afenumber, INSTR(c.afenumber,'10'),8)

0
 
SStoryCommented:
I'm not sure in Oracle, but if there are two cases then you'd use the
CASE and When keywords in SQL Server
0
 
SStoryCommented:
select c.afenumber
where LEFT(c.afenumber,2)='10'

Doesn't this work in oracle?  if not use SUBSTR to get first two letters
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.