Quick Search:
 
 The Oracle PL/SQL ROUND Function      [Return To Index] Jump to:  

Term: ROUND

Definition:
In Oracle, ROUND is a built in overloaded function, which is used to round off numeric and DATE type inputs to a specified precision.

Example Syntax:

ROUND( n, X)


In the syntax example above, "n" can be a numeric or date type input. "X" is the rounding format. Date type inputs can be rounded by year, month, quarter, week, hour and minute.

Example Usage:

The below set of SQL statements show the use of the ROUND function with both Number and Date inputs. In the first two examples, note the difference in the results by having positive and negative precisions. If the precision is positive, it rounds the digits which are placed after the decimal. For negative precision values, it rounds the digits which are placed before the decimal place.

SQL> SELECT ROUND(1.2536,2) FROM DUAL;

ROUND(1.2536,2)
---------------
1.25

SQL> SELECT ROUND(1234,-2) FROM DUAL;

ROUND(1234,-2)
--------------
1200

SQL> SELECT ROUND(TO_DATE('02-AUG-2011','DD-MM-YYYY'),'YYYY') FROM DUAL;

ROUND(TO_
---------
01-JAN-12

SQL> SELECT ROUND(TO_DATE('02-AUG-2011','DD-MM-YYYY'),'MM') FROM DUAL;

ROUND(TO_
---------
01-AUG-11



Related Links:

Related Code Snippets:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org