Remove the last value found inside a string

Asked

Viewed 1,658 times

0

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

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

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

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, already the Urge looks for the position of a character inside the "string", when we pass -1 in the last parameter it looks upside down.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.