Home » Oracle » ROUND() Function in Oracle SQL Plus
ROUND() Function in Oracle SQL Plus
By Jerry Gale March 07, 2011 The ROUND() Function is used to return the rounded values of a numeric field to the number of decimals specified.
ROUND() FUNCTION
The ROUND FUNCTION is used to round a numeric column. We need to specify the number of decimals.
Syntax :
SELECT column_name(s), ROUND(column_name, Decimals) FROM table_name;
Example :
Table Products:
From the above table we want to list Id, Product & rounded value of column Price (to one decimal place), we'll execute the following SQL Query:
SELECT Id, Product, ROUND(Price, 1) FROM Products;The following result will be produced :
Now we want to list Id, Product & rounded value of column Price (without any decimal place), we'll execute the following SQL Query:
SELECT Id, Product, ROUND(Price, 0) FROM Products;The following result will be produced :
Now we want to list Id, Product & rounded value of column Price (one digit to the left of the decimal place), we'll execute the following SQL Query:
SELECT Id, Product, ROUND(Price, -1) FROM Products;The following result will be produced :
Now we want to list Id, Product & rounded value of column Price (two digit to the left of the decimal place), we'll execute the following SQL Query:
SELECT Id, Product, ROUND(Price, -2) FROM Products;The following result will be produced :


0 comments:
Post a Comment