Returns the value of the specified number, rounded to a specified number of decimal places.
round(number, decimal_places)
is any exact numeric (numeric, dec, decimal, tinyint, smallint, int, or bigint), approximate numeric (float, real, or double precision), or money column, variable, constant expression, or a combination of these.
is the number of decimal places to round to.
select round(123.4545, 2)
---------- 123.4500
select round(123.45, -2)
---------- 100.00
select round(1.2345E2, 2)
----------------- 123.450000
select round(1.2345E2, -2)
----------------- 100.000000
round, a mathematical function, rounds the number so that it has decimal_places significant digits.
A positive value for decimal_places determines the number of significant digits to the right of the decimal point; a negative value for decimal_places determines the number of significant digits to the left of the decimal point.
Results are of the same type as number and, for numeric and decimal expressions, have an internal precision equal to the precision of the first argument plus 1 and a scale equal to that of number.
round always returns a value. If decimal_places is negative and exceeds the number of significant digits specified for number, Adaptive Server returns 0. (This is expressed in the form 0.00, where the number of zeros to the right of the decimal point is equal to the scale of numeric.) For example, the following returns a value of 0.00:
select round(55.55, -3)
For general information about mathematical functions, see “Mathematical functions”.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute round.