Friday, May 3, 2013

oracle trunc number function

oracle trunc number function

                   truncates the specified value to specified decimal places.

SYNTAX: trunc(n1,n2)
     it truncates n1 by n2 decimal places

for ex: trunc(15.71, 1)  ->outputs 15.7 

SQL> select trunc(15.71) from dual;

TRUNC(15.71)
------------
          15

*Default  0.



SQL> select trunc(15.71,-1) from dual;

TRUNC(15.71)
------------
          10


GET Fractional PORTION OF THE REAL VALUE.
--------------------------------------------

SQL> select 15.71-trunc(15.71,0) from dual;

15.71-TRUNC(15.71,0)
--------------------
                 .71



No comments:

Post a Comment