Working with plsql I am dividing two numbers, and would like to receive only what comes after the comma. Ex: 7.89111. I just need the number 89111.
Working with plsql I am dividing two numbers, and would like to receive only what comes after the comma. Ex: 7.89111. I just need the number 89111.
Expensive,
The only way I found it was by converting the number to String and making a substring with it.
I put the value with the dot instead of comma to take the test, but you can put your field in the two values that works fine.
select substr(to_char(7.89111), instr(to_char(7.89111), ',') + 1) from dual;
Result:
SUBST
-----
89111
I would do this, you do not need to convert the value to string, then when you perform a calculation with it, you will have to convert it back to number ...
SELECT SUBSTR (7.89111, INSTR (7.89111, '.', 1, 1) + 1, 5) value FROM dual;
If you want to get the decimal part, do this:
SELECT 7.89111 - TRUNC(7.89111) from dual;
Result: 0,89111
If you just want to get the numbers after the comma:
select REPLACE((7.89111 - trunc(7.89111)),',','') from dual;
Result: 89111