FLOOR()
nikolaspoczekaj19 total contributions
Published May 26, 2023
Contribute to Docs
The SQL math function FLOOR()
returns the largest integer that is less than or equal to a specified numeric value. It effectively rounds down a number to the nearest whole integer.
Syntax
SELECT FLOOR(number)FROM table_name;
number
- The value which will be floored / rounded down.
Example
In this example, the following data is given, in a table named employees
:
employee_id | salary |
---|---|
1 | 3500.27 |
2 | 1530.90 |
3 | 3025.10 |
4 | 5040.50 |
The FLOOR()
function can be used to return the largest integer that is less than or equal to a given value:
SELECT employee_id, FLOOR(salary) AS floored_salaryFROM employees;
In this SQL statement, the salary
values are floored for each employee to get the floored_salary
. The AS
keyword is used to name the resulting column floored_salary
in the output.
The output will be:
employee_id | floored_salary |
---|---|
1 | 3500 |
2 | 1530 |
3 | 3025 |
4 | 5040 |
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.