FLOOR
Declaration
FLOOR(expr)
Description
The FLOOR function returns the largest integer that is less than or equal to the specified expression. It is similar to the CEIL(expr) function.
The function supports comparison operations and returns a BOOLEAN value, which is then converted to a numeric type. The result is 1 for TRUE and 0 for FALSE.
If the input is NULL, the function returns NULL.
If the input is a string that represents a number, it is automatically converted to a numeric type.
The result is returned as a BIGINT.
Examples
SELECT FLOOR(1.2), FLOOR(-1.2), FLOOR(1+1.5), FLOOR(1=1),FLOOR(1<1),FLOOR(null);
+------------+-------------+--------------+------------+------------+-------------+
| FLOOR(1.2) | FLOOR(-1.2) | FLOOR(1+1.5) | FLOOR(1=1) | FLOOR(1<1) | FLOOR(null) |
+------------+-------------+--------------+------------+------------+-------------+
| 1 | -2 | 2 | 1 | 0 | NULL |
+------------+-------------+--------------+------------+------------+-------------+
1 row in set (0.001 sec)
SELECT FLOOR('2');
+------------+
| FLOOR('2') |
+------------+
| 2 |
+------------+
1 row in set (0.001 sec)