ROUND (SQL Server Compact Edition)
Returns a numeric expression, rounded to the specified length or precision.
Syntax
ROUND ( numeric_expression, length [ , function ] )
Arguments
- numeric_expression
An expression of the exact numeric or approximate numeric data type categories, or types that are implicitly convertible to float.
- length
The precision to which numeric_expression is to be rounded. When length is a positive number, numeric_expression is rounded to the number of decimal places specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length.
- function
The type of operation to perform. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.
Return Value
Returns the same type as numeric_expression except for the following expressions.
Specified expression | Return type |
---|---|
tinyint, smallint |
int |
real/float |
float |
Nonnumeric types that can be implicitly converted to float |
float |
Example
The following example returns the unit price, rounded to the nearest dollar, of products listed in the Products table.
SELECT UnitPrice, ROUND(UnitPrice, 0)
FROM Products