Retrieve the last value found inside a string

0

I need to take an average of payment terms in the database and I came across the situation where the condition column is a string and it can receive parcel values separated by slash. I need to get the last value after the last bar, percent sign or value. Here is an example:

select '28/30/56', '10%60%30%', '12 dias'
from dual;

The output should be: 56, 30, 12 ...

    
asked by anonymous 20.02.2018 / 19:35

1 answer

0
SELECT substr('28/30/56',Instr('28/30/56', '/',-1) +1 ,2), '10%60%30%', '12 dias' FROM DUAL;

The substr takes a certain range within a string, Instr searches the position of a character inside the string, when we pass -1 in the last parameter it searches for inverted form.

    
20.02.2018 / 21:01