Round down SQL Server to an integer

SQL ROUND () Function

The ROUND () function

The ROUND () function is used to round a numeric field to the number of decimal places specified.

Note: Many database systems have rounding different from what one might expect. When rounding a number with a fraction to an integer, our teacher told us to round 0.1-0.4 down to the next lower whole number, and 0.5-0.9 UP to the next higher whole number. But if all digits from 1 to 9 are equally likely, this presents a slight tendency towards infinity, since we are always around 0.5. Many database systems have adopted the IEEE 754 standard for arithmetic operations, according to which the standard behavior is rounding "around half even." In this scheme, 0.5 is rounded to the nearest even whole number. So both 11.5 and 12.5 would be rounded to 12.

SQL ROUND () syntax

SELECT ROUND (column_name, decimals) FROM table_name;
parameter description
column_name Required. To round the field.
decimals Required. Returns the number of decimal places to be returned.

Demo database

In this tutorial we will use the well-known sample database.

Below is a selection from the "Products" table:

Product ID Product name Supplier ID Category ID unit price
1Chais1110 boxes x 20 bags18
2Chang1124 - 12 oz bottles19
3Aniseed Syrup1212 - 550 ml bottles10
4Chef Anton's Cajun Seasoning2248 - 6 oz jars21.35
5Chef Anton's Gumbo Mix2236 boxes25

SQL ROUND () example

The following SQL statement selects the product name and rounds the price in the "Products" table: