Overview
The ROUND
function returns a numeric value rounded to the specified length or precision.
Syntax
ROUND ( numeric_expression , length [ ,function ] )
Parameters
Parameter | Description |
---|---|
numeric_expression | Expression of a numeric data type. |
length | Precision to which to round. Positive values round to the right of the decimal point; negative values round to the left. |
function | Optional. When 0 (default) or omitted, numeric_expression is rounded. When any other value is specified, numeric_expression is truncated. |
Return Type
Returns the same data type as numeric_expression
.
Remarks
- If
numeric_expression
isNULL
, the result isNULL
. - When
function
= 0 or omitted, the number is rounded; otherwise it is truncated. - For
float
andreal
data types, rounding follows IEEE standards.
Examples
Basic rounding
SELECT ROUND(123.4567, 2) AS RoundedValue; -- 123.46
Rounding to the left of the decimal point
SELECT ROUND(123.4567, -2) AS RoundedValue; -- 100.0000
Truncating instead of rounding
SELECT ROUND(123.4567, 2, 1) AS TruncatedValue; -- 123.45