SQL Server Tutorial SQL Server Advanced SQL Server Database SQL Server References

SQL Server - FLOOR() Function



The SQL Server (Transact-SQL) FLOOR() function returns the next lowest integer value by rounding down the specified number, if necessary. In other words, it rounds the fraction DOWN of the given number.

Syntax

FLOOR(x)

Parameters

x Required. Specify a number.

Return Value

Returns the next lowest integer value by rounding DOWN the specified number, if necessary.

Example 1:

The example below shows the usage of FLOOR() function.

SELECT FLOOR(23);
Result: 23

SELECT FLOOR(23.3);
Result: 23

SELECT FLOOR(23.8);
Result: 23

SELECT FLOOR(-23);
Result: -23

SELECT FLOOR(-23.3);
Result: -24

SELECT FLOOR(-23.8);
Result: -24

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 1-10.75
Data 2-5.38
Data 30.98
Data 413.16
Data 548.13

The statement given below can be used to round the fraction DOWN for all records of column x.

SELECT *, FLOOR(x) AS FLOOR_Value FROM Sample;

This will produce the result as shown below:

DataxFLOOR_Value
Data 1-10.75-11
Data 2-5.38-6
Data 30.980
Data 413.1613
Data 548.1348

❮ SQL Server Functions