SQL ROUND() Function
The 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
;
| Parameters | Description |
|---|---|
| column_name | Required. The field to round. |
| decimals | Optional. Specifies the number of decimal places to return. |
SQL ROUND() Examples
ROUND(X): Returns an integer that is argument X rounded to the nearest whole number.
Example
mysql
SELECT
ROUND
(
1.23
)
;
->
1
mysql
SELECT
ROUND
(
1.58
)
;
->
2
mysql
SELECT
ROUND
(
1.58
)
;
->
2
ROUND(X,D): Returns a number that is argument X rounded to D decimal places. If D is 0, the result will have no decimal point or fractional part.
Example
mysql
SELECT
ROUND
(
1.298
,
1
)
;
->
1.3
mysql
SELECT
ROUND
(
1.298
,
0
)
;
->
1
Note: The ROUND return value is converted to a BIGINT!