SQL ROUND() Function

ROUND() Function

The ROUND function is used to round a numeric field to a specified number of decimal places.

SQL ROUND() Syntax

SELECT ROUND(column_name,decimals) FROM table_name
Parameter Description
column_name Required. The field to be rounded.
decimals Required. Specifies the number of decimal places to return.

SQL ROUND() Example

We have the following 'Products' table:

Prod_Id ProductName Unit UnitPrice
1 gold 1000 g 32.35
2 silver 1000 g 11.56
3 copper 1000 g 6.85

Now, we want to round the name and price to the nearest integer.

We use the following SQL statement:

SELECT ProductName, ROUND(UnitPrice,0) as UnitPrice FROM Products

The result set is similar to this:

ProductName UnitPrice
gold 32
silver 12
copper 7