Link to home
Start Free TrialLog in
Avatar of Mark_1976
Mark_1976

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of GGuzdziol
GGuzdziol
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark_1976
Mark_1976

ASKER

Thanks - that's done the trick.
Just curious - are You going to click Accept?
invoice
-------------
   Qty
-------------
  150.023
 1508.023

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

 Result is :
-------
150.0
1508.0