Website logo
⌘K
šŸ Homepage
šŸ‘‹Introduction
Key Concepts & Architecture
šŸš€Run Oxla in 2 minutes
šŸƒā€ā™‚ļøRun Oxla on S3
šŸ›«Multi-node Deployment
šŸ‘Øā€šŸ’»SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
Comment Support
ā›“ļøSQL Mutations
DELETE
UPDATE
🚨Error Handling
šŸ†šDifferences Between Oxla vs. PostgreSQL
šŸ”„Understanding Transactions
šŸ“ˆPublic Metrics
āš™ļøOxla Configuration File
✨Changelog
Docs powered byĀ Archbee
SQL Reference
...
SQL Functions
Numeric Functions

CEIL

9min

Overview

The CEIL() function returns the nearest positive or negative integer value greater than or equal to the provided decimal input number.

Syntax

The syntax of the CEIL() function is as follows:

Syntax
CEIL(x)


The CEIL() 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 up a positive decimal value

The following example demonstrates how the CEIL() function rounds up a positive decimal value:

Select ceil
SELECT CEIL (300.55);


As shown below, it will return 301, as it is the nearest integer value greater than 300.55.

Output
+------+
| f    |
+------+
| 301  |
+------+


Case #2: Rounding up a negative decimal value

The following example demonstrates how the CEIL() function rounds up a negative decimal value:

Select ceil
SELECT CEIL(-89.9) AS "Ceil";


The output of this statement will be -89, as -89 is the nearest integer value greater than or equal to -89.9, as shown below.

Output
+-------+
| Ceil  |
+-------+
| -89   |
+-------+


Case #3: Using the CEIL() function with a table

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

1) First, create a table called CeilRecords with the following query:

Create table
CREATE TABLE CeilRecords (numbers float);
  
INSERT INTO CeilRecords(numbers) 
VALUES 
    (-28.85),
    (-9.4),
    (0.87),
    (78.16),
    (42.16);


The above statement will create a table called "CeilRecords" with a column called "numbers" and insert 5 decimal values into it.

2) The statement below can be used to retrieve and round up the value for all records in the column numbers:

Select ceil
SELECT *, CEIL(numbers) AS CeilValue FROM CeilRecords;


The final result will contain the following:

  • A numbers column with initial decimal values.
  • A CeilValue column with rounded-up integer values.
Output
+---------+------------+
| numbers  | CeilValue  |
+---------+------------+
| -28.85  | -28        |
| -9.4    | -9         |
| 0.87    | 1          |
| 78.16   | 79         |
| 42.16   | 43         |
+---------+------------+




Updated 09 Oct 2023
Did this page help you?
PREVIOUS
Numeric Functions
NEXT
ABS
Docs powered byĀ Archbee
TABLE OF CONTENTS
Overview
Syntax
Examples
Case #1: Rounding up a positive decimal value
Case #2: Rounding up a negative decimal value
Case #3: Using the CEIL() function with a table
Docs powered byĀ Archbee

©2023 Oxla