FLOOR

FLOOR is a mathematical function provided by SQL, used to round down a given number to the nearest whole integer value, essentially returning the largest integer that is less than or equal to the number in question.

FLOOR(X)

  • x: The numerical expression or decimal number that will be rounded down to the nearest smaller or equal integer.

Example

SELECT FLOOR(1.99);

Output

1

Explanation

The FLOOR() function in MySQL is used to return the largest integer value that is less than or equal to a given number. In this example, since the provided number is 1.99, the FLOOR() function produces the output of 1, which is the largest integer that is less or equal to 1.99.

FLOOR(numeric) RETURNS numeric

  • numeric: The number for which the floor value is to be calculated. In this SQL function, FLOOR(numeric) RETURNS numeric, the ‘numeric’ refers to any numeric value. The function will return the largest integer value that is less than or equal to the provided numeric value.

Example

SELECT FLOOR(42.8);

Output

42

Explanation

The FLOOR function in PostgreSQL provides the largest integer less than or equal to the specified number. In this example, the FLOOR function returns the largest integer less than or equal to 42.8, which is 42.

FLOOR( numeric_expression )

  • numeric_expression: This is the numeric value or variable for which the floor value needs to be calculated. The function returns the largest integer less than or equal to the provided numeric_expression.

Example

SELECT FLOOR(15.75) AS FloorValue;

Output

FloorValue
15

Explanation

The FLOOR function in SQL Server rounds the specified float expression or decimal number down to the nearest integer. In the example, FLOOR(15.75) returns 15 because 15 is the nearest integer that is less than 15.75.

FLOOR(number)

  • number: This parameter refers to the numeric value or expression for which the function would return the highest integer value but not greater than the supplied number.

Example

SELECT FLOOR(15.75) FROM dual;

Output

15

Explanation

The FLOOR function returns the largest integer value that is smaller than or equal to a number. In this case, the number is 15.75, so the largest integer that is smaller than or equal to 15.75 is 15.

FLOOR(X)

  • x: This is the numeric expression that is to be rounded down. FLOOR(X) function returns the largest integer value that is less than or equal to X.

Example

SELECT FLOOR(42.86);

Output

42

Explanation

The function FLOOR() rounds down the provided decimal number to the nearest lower integer. In the example, the decimal number 42.86 is rounded down to 42.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.