Pick up number after the comma

0

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.

    
asked by anonymous 26.10.2015 / 15:35

3 answers

2

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
    
26.10.2015 / 15:59
1

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;

    
09.11.2015 / 13:42
1

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

    
26.01.2017 / 12:52