floor
1. FLOOR Function
=======floor
1. FLOOR Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe FLOOR function in H2 database is used to round down a numeric value to the nearest integer that is less than or equal to the given value.
2. Syntax
The syntax for the FLOOR function in H2 database is as follows:
FLOOR(value)
Arguments
value
: The numeric value that needs to be rounded down. It can be of any numeric data type.
Return
- The FLOOR function returns the rounded down value as an integer.
3. Notes
- The FLOOR function in H2 database always returns an integer value.
- If the input value is already an integer, the FLOOR function will return the same value.
- If the input value is
NULL
, the FLOOR function will also returnNULL
.
4. Examples
Here are a few examples demonstrating the usage of the FLOOR function in H2 database:
Example 1 - Rounding down a decimal value:
SELECT FLOOR(3.7) AS rounded_value;
Output:
rounded_value
-------------
3
Example 2 - Rounding down a negative value:
SELECT FLOOR(-2.5) AS rounded_value;
Output:
rounded_value
-------------
-3
Example 3 - Rounding down a column of values:
CREATE TABLE numbers (
id INT PRIMARY KEY,
value DOUBLE
);
INSERT INTO numbers VALUES (1, 4.8), (2, 2.3), (3, 9.9);
SELECT id, value, FLOOR(value) AS rounded_value
FROM numbers;
Output:
id | value | rounded_value
---+-------+---------------
1 | 4.8 | 4
2 | 2.3 | 2
3 | 9.9 | 9
5. Related Functions
- CEILING - Round up to the nearest integer
- round - Round to the nearest integer