How to extract fractional part from number per sql in oracle?
5 answers
It's simple:select mod(12.345, 1) from dual;
will return 0.345
|
Not the fact that on Oracle
will go, but an essence such:
select abs( num - cast( num as bigint ) ) as num from ( select num = -123.123 ) t
|
declare x number(12,4) := 12.345; begin dbms_output.put_line(x - floor(x)); exception when others then dbms_output.put_line(sqlcode || ' ' || sqlerrm); end;
|
The mod () function - http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions101.htm
|
The fractional part can be extracted, for example, as follows:
x - trunc(x)
- brought the answer to a normal form. I have no idea about the correctness of the answer. - aleksandr barakin
- onethe answer was reduced to a blunt mind, the same as the system forcing to write 30 characters where there is enough 12 - Diver
|