website logo
⌘K
🏠Homepage
👋Introduction
Key Concepts & Architecture
🚀Getting Started
👨‍💻SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
🚨Error Handling
🆚Differences Between Oxla vs. PostgreSQL
Docs powered by archbee 

FLOOR

11min

This article will guide you on how to use the FLOOR() function, with its syntax and examples.

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:

Syntax
|
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
|
SELECT FLOOR(345.6765467);


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

Output
|
+------+
| 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
|
SELECT FLOOR(-0.987657);


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

Output
|
+-------+
| 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 a table
|
CREATE TABLE FloorRecords (numbers float);
INSERT INTO FloorRecords VALUES (3.987), (4.325), (-0.76), (-22.57);


2) Retrieve the table with its value by running the following query:

Select floor
|
SELECT * ,FLOOR(numbers) AS Floorvalue FROM FloorRecords;


3) The return table will contain the following:

  • numbers, the column with the initial double-precision values.
  • FloorValue, the column with the rounded-down values. 
Output
|
+------------+---------------+
| numbers    | Floorvalue    |
+------------+---------------+
| 3.987	     | 3             |
| 4.325	     | 4             |
| -0.76	     | -1            |
| -22.57     | -23           |
+------------+---------------+




Updated 11 May 2023
Did this page help you?
Yes
No
PREVIOUS
RANDOM
NEXT
LN
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Syntax
Examples
Case #1: Rounding Down a Positive Decimal Value
Case #2: Rounding Down a Negative Decimal Value
Case #3: Using the FLOOR() Function With a Table

Dedicated to data analytics that provides 10x faster execution of analytical queries than current state of the art solutions. We are launching SOON! Join the waiting list for more info.




©2022 Oxla