How to extract a group of numbers

Posted on 2009-04-27
Last Modified: 2013-12-19

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:

10204022 - Reco

Any suggestions?

Question by:mskitten
    LVL 25

    Expert Comment

    I'm not sure in Oracle, but if there are two cases then you'd use the
    CASE and When keywords in SQL Server

    Accepted Solution

    If all the numbers I need start with '10', this might be all I need:

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

    LVL 25

    Expert Comment

    select c.afenumber
    where LEFT(c.afenumber,2)='10'

    Doesn't this work in oracle?  if not use SUBSTR to get first two letters

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
    This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now