• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

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?


0
mskitten
Asked:
mskitten
  • 2
1 Solution
 
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
 
mskittenAuthor 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:
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

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now