
To round up to 4 digits, change the data type of the input. Results in an arithmetic overflow, because 748.58 defaults to decimal(5,2), which cannot return 1000.00. ROUND returns a rounded numeric_expression, regardless of data type, when length is a negative number. If length is negative and larger than the number of digits before the decimal point, ROUND returns 0. When a value other than 0 is specified, numeric_expression is truncated. When function is omitted or has a value of 0 (default), numeric_expression is rounded. function must be tinyint, smallint, or int. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length. When length is a positive number, numeric_expression is rounded to the number of decimal positions specified by length. length must be an expression of type tinyint, smallint, or int. Is the precision to which numeric_expression is to be rounded. Is an expression of the exact numeric or approximate numeric data type category. Rounding a single-column table of values.To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation. Rounding to two decimal places to the left of the decimal separator (100).

Rounding to two decimal places to the right of the decimal separator (0.01). Use a positive value to indicate decimal places right of the decimal separator, a negative value to the left, and zero for a whole number. Use ShowColumns and other table shaping functions to extract a single-column table from a larger table. If the single-column table has less values that the Number, zero is used for the remaining values. The DecimalPlaces parameter can be a single value or a single-column table. If you pass a single-column table that contains numbers, the return value is a single-column table of rounded numbers. If you pass a single number, the return value is the rounded version of that number. These functions support single-column tables. Use RoundDown instead when this is needed. Use Trunc to extract the decimal portion of a number by subtracting it from the original, for example X - Trunc(X).ĭecimal places cannot be specified with Trunc as it can with Microsoft Excel. Int returns values that are unique amongst the five rounding functions, while Trunc returns the same values as RoundDown. For example, for an argument of -4.3, Int will return the integer further away from zero, -5, while Trunc will return the integer closer to zero, -4. The difference between Int and Trunc is in the handling of negative numbers.

The Int and Trunc functions round a number to an integer (whole number without a decimal): The number is rounded to the left of the decimal separator. The number is rounded to the nearest integer. The number is rounded to the right of the decimal separator. The number of decimal places can be specified for these functions: Decimal places RoundUp always rounds up to the next higher number, away from zero.RoundDown always rounds down to the previous lower number, towards zero.Round rounds up if the next digit is 5 or higher.The Round, RoundDown, and RoundUp functions round a number to the specified number of decimal places:
