Pages

Sunday, 27 March 2011

ROUND() Function in Oracle SQL Plus

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.

Similar ArticlesMost ReadTop RatedLatest


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:

ROUND-IMG-1.gif

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 :

ROUND-IMG-2.gif

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 :

ROUND-IMG-3.gif

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 :

ROUND-IMG-4.gif

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 :

ROUND-IMG-5.gif

Login to add your contents and source code to this article C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.

View the original article here

0 comments:

Post a Comment

 
Powered by Blogger