SQL to extract substring from VARCHAR2

Hi,

I'm hoping someone can help. I have a VARCHAR2 field from which I need to extract a specific peice of the string. The problem is that this is not always in the same place in the string, e.g. I want to extract 300.0 from here:

Account No.: 0020495
Account Type: MAXI_ISA
Fund: Invesco Perpetual Income Inc
Symbol: 187261.SFU
ISIN: GB0033053827
Quantity: 300.0
Channel: Internet

but sometimes the value may start at a different location, and be a different length, like so

Account No.: 0025692
Account Type: DEALING
Fund: Cf Ruffer European Fund Acc
Symbol: 196448.SFU
ISIN: GB0001678161
Quantity: 2720.027
Channel: Internet

Can anyone help?

Thanks

Mark
Mark_1976Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GGuzdziolCommented:
SQL> select * from t;

T
-------------------------------------------------------------------------------------------------------------------

Account No.: 0025692
Account Type: DEALING
Fund: Cf Ruffer European Fund Acc
Symbol: 196448.SFU
ISIN: GB0001678161
Quantity: 2720.027
Channel: Internet

Account No.: 0020495
Account Type: MAXI_ISA
Fund: Invesco Perpetual Income Inc
Symbol: 187261.SFU
ISIN: GB0033053827
Quantity: 300.0
Channel: Internet


SQL> select substr(t, instr(t, chr(10), 1, 5) + 11, instr(t, chr(10), 1, 6) - instr(t, chr(10), 1, 5) - 11) from t;

SUBSTR(T,INSTR(T,CHR(10),1,5)+11,INSTR(T,CHR(10),1,6)-INSTR(T,CHR(10),1,5)-11)
-------------------------------------------------------------------------------------------------------------------

2720.027
300.0

HTH,
Grzegorz

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark_1976Author Commented:
Thanks - that's done the trick.
GGuzdziolCommented:
Just curious - are You going to click Accept?
Tareq_AsebieCommented:
invoice
-------------
   Qty
-------------
  150.023
 1508.023

select substr(Qty,1,instr(Qty,'.',1)+1) from invoice

 Result is :
-------
150.0
1508.0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.