Returns a numeric expression, rounded to the specified length or precision.
ROUND(numeric_expression, length[, function])
Returns the same type as numeric_expression.
ROUND always returns a value. If length is negative and larger than the number of digits before the decimal point, ROUND returns 0.
Example | Result |
---|---|
ROUND(748.58, -4) | 0 |
In Microsoft® SQL Server™ version 7.0, ROUND returns a rounded numeric_expression, regardless of data type, when length is a negative number.
Examples | Result |
---|---|
ROUND(748.58, -1) | 750.00 |
ROUND(748.58, -2) | 700.00 |
ROUND(748.58, -3) | 1000.00 |
This example shows two expressions illustrating that with the ROUND function the last digit is always an estimate.
SELECT ROUND(123.9994, 3), ROUND(123.9995, 3)
GO
Here is the result set:
----------- -----------
123.9990 124.0000
This example shows rounding and approximations.
Statement | Result |
---|---|
SELECT ROUND(123.4545, 2) |
123.4500 |
SELECT ROUND(123.45, -2) |
100.00 |
This example uses two SELECT statements to demonstrate the difference between rounding and truncation. The first statement rounds the result. The second statement truncates the result.
Statement | Result |
---|---|
SELECT ROUND(150.75, 0) |
151.00 |
SELECT ROUND(150.75, 0, 1) |
150.00 |
CEILING | FLOOR |
Data Types | Mathematical Functions |
Expressions |