Overview

The FLOOR() returns a number rounded down that is less than or equal to the specified argument.

Syntax

The syntax for the FLOOR() function in Oxla is:

FLOOR(x)

The FLOOR() function requires one argument:

x: A positive or a negative decimal number (or an expression that evaluates to a decimal number).

Examples

Case #1: Rounding Down a Positive Decimal Value

The following example demonstrates how the FLOORL() function rounds down a positive decimal value:

SELECT FLOOR(345.6765467);

It will return 345 as it is the closest value smaller than the argument.

+------+
| f    |
+------+
| 345  |
+------+

Case #2: Rounding Down a Negative Decimal Value

The following example demonstrates how the FLOORL() function rounds down a negative decimal value:

SELECT FLOOR(-0.987657);

You will get the following result as it is the nearest integer smaller than or equal to the specified argument.

+-------+
| f     |
+-------+
| -1    |
+-------+

Case #3: Using the FLOOR() Function With a Table

The following example demonstrates how the FLOOR() function can be used with a table to round down the values in a specific column:

  1. Create a new table called FloorRecords with double-precision values using the query below:
CREATE TABLE FloorRecords (numbers float);
INSERT INTO FloorRecords VALUES (3.987), (4.325), (-0.76), (-22.57);
  1. Retrieve the table with its value by running the following query:
SELECT * ,FLOOR(numbers) AS Floorvalue FROM FloorRecords;
  1. The return table will contain the following:
  • numbers, the column with the initial double-precision values.

  • FloorValue, the column with the rounded-down values. 

+------------+---------------+
| numbers    | Floorvalue    |
+------------+---------------+
| 3.987	     | 3             |
| 4.325	     | 4             |
| -0.76	     | -1            |
| -22.57     | -23           |
+------------+---------------+