Friday, May 3, 2013

ORACLE ROUND FUNCTION

ORACLE ROUND FUNCTION

                                  Round function rounds the number into nearest integer


round(decimal number, n);


SQL>select round(17.7) from dual;  --rounds to 18
SQL> select round(17.49) from dual; --rounds to 17.

Note: the number >.5 will be rounded to next integer <0.5 rounded to lowest number.


SQL>select round(17.7,1) from dual;

SQL> select round(17.71,1) from dual;

ROUND(17.71,1)
--------------
          17.7

SQL> select round(17.7,1) from dual;

ROUND(17.7,1)
-------------
         17.7

SQL> select round(17.7,10) from dual;

ROUND(17.7,10)
--------------
          17.7

SQL> select round(17.9,10) from dual;

ROUND(17.9,10)
--------------
          17.9

SQL> select round(17.99,10) from dual;

ROUND(17.99,10)
---------------
          17.99

SQL> select round(17.999,1) from dual;

ROUND(17.999,1)
---------------
             18

SQL> select round(17.9,1) from dual;

ROUND(17.9,1)
-------------
         17.9

SQL> select round(17.99,1) from dual;

ROUND(17.99,1)
--------------
            18

SQL> select round(17.56,1) from dual;

ROUND(17.56,1)
--------------
          17.6

SQL> select round(17.55,1) from dual;

ROUND(17.55,1)
--------------
          17.6

SQL> select round(17.49,1) from dual;

ROUND(17.49,1)
--------------
          17.5

1 comment:

  1. select round(17.5,-1) from dual;
    o/p:-20
    is correct or not send me reply

    ReplyDelete