-1

how to get an exact number from a string in SQL. I have a string like 'the total amounts is 12.30 rupees and vat' in this string i want to extract 12.3 for calculation purposes in SQL, NetSuite formula field

I have tried replace function to get all numerics from a string but it getting 1230 instead of 12.30 so it is not consider a dot.

2 Answers2

0

Using a simple regex expression, you can get the numeric value

select regexp_substr('the total amounts is 12.30 rupees and vat', '\d+\.?\d+?') from dual;
EJ Egyed
  • 5,791
  • 1
  • 8
  • 23
0
SELECT REGEXP_SUBSTR('Test 12.30 test', '-?\d+(\.\d+)?')
FROM dual;

oracle regular expression to extract decimal numbers from string

Dietz
  • 18
  • 3