SQL ROUND()

Posted by Monir Hossain On 9:57:00 am | No comments

SQL ROUND() Function


The ROUND() Function

The ROUND() function is used to round a numeric field to the number of decimals specified.

SQL ROUND() Syntax

SELECT ROUND(column_name,decimals) FROM table_name;

ParameterDescription
column_nameRequired. The field to round.
decimalsRequired. Specifies the number of decimals to be returned.


Demo Database

In this tutorial we will use the well-known Northwind sample database.
Below is a selection from the "Products" table:
ProductIDProductNameSupplierIDCategoryIDUnitPrice
1Chais1110 boxes x 20 bags18
2Chang1124 - 12 oz bottles19
3Aniseed Syrup1212 - 550 ml bottles10
4Chef Anton's Cajun Seasoning2248 - 6 oz jars21.35
5Chef Anton's Gumbo Mix2236 boxes25


SQL ROUND() Example

The following SQL statement selects the product name and the price rounded to the neares integer from the "Products" table:

Example

SELECT ProductName, ROUND(Price,0) AS RoundedPrice
FROM Products;

Try it yourself »


0 comments:

Post a Comment

Blogroll

E COMMERCE

BANGLA PAPER

ENGLISH PAPER

Blogger news

About

E COMMERCE

BANGLA PAPER

ENGLISH PAPER