Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL ROUND Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

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      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 143 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?