Wednesday, October 13, 2021

Round function

Returns a number rounded to a specified number of decimal places.

Syntax

Round( expression [, numdecimalplaces ] )

The Round function syntax has these arguments:

Argument

Description

expression

Required. Numeric expression being rounded.

numdecimalplaces

Optional. Number indicating how many places to the right of the decimal are included in the rounding. If omitted, the function rounds to the nearest whole number.

Note: This VBA function returns something commonly referred to as bankers rounding. So be careful before using this function. For more predictable results, use Worksheet Round functions in Excel VBA.

Query examples

Expression

Results

SELECT ProductSales.ProductID, Round(FinalPrice) AS Expr1 FROM ProductSales;

Returns the Product ID along with "FinalPrice" rounded to the closest number (without decimal).

SELECT ProductSales.ProductID, Round(FinalPrice,1) AS RoundedPrice FROM ProductSales;

Returns the Product ID along with "FinalPrice" rounded to the closest number with 1 decimal and displays in the column RounderPrice.

No comments:

Post a Comment