×

MySQL CEILING() function

In this context, we will learn how we can use the MySQL CEILING () function with proper syntax and good examples.

Introduction of MySQL CEILING () function

The CEILING() function accepts the inputs by user and give back the smallest integer value that is greater than or equal to that mentioned number.

For instance, if a mentioned number is 5.7, the CEILING() function will give back the integer value of 6, which is greater than 5.7, or on the other hand, if a specified integer is 7, then the function will give back 7 that is equal to 7.

Important characteristics of MySQL CEILING() function:

  • The prime use of this function is to find the smallest integer value which is greater than or the same as the mentioned integer.
  • A single parameter is accepted by this function.
  • The parameter which is accepted by this function can be a numeric value of an integer or float data type.

Syntax of the MySQL CEILING() function:

CEILING ( num );

Parameter or argument used in MySQL CEILING function:

Only one parameter is accepted by this method:

Num- This is the mentioned numeric value.

Returns- It will return the smallest integer value that is greater than or equal to a mentioned number.

Some examples of MySQL CEILING function:

Example: 1

Here, we will get the smallest integer, 1, which is greater than the mentioned numeric value 0.7.

SELECT CEILING( 0.7 );

Now the output is :

1

Example: 2

Here, we will get the smallest number, 4, which is greater than the mentioned numeric value “ 3.141592635 ”, which is the value of pi.
Here the function of pi returns the value of pi, and after that, the function CEILING function takes the pi value as an argument and gives us the output as 4.

SELECT CEILING( pi());

Now the output is:

4

Example: 3

Here, we will get the number 15, which is the same as the given back random value among 7 and 20.

A random number between 7 and 20 will be returned by the floor function, and after that, the CEILING function() takes the returned value as an argument and will return the same number, 15.

SELECT CEILING(floor( 7 + rand () * ( 20 - 7 + 1)));

Now the output is:

14

Example: 4

Here, we will get the smallest integer value, 545, which is greater than the specified numeric value “544.7”, which is the absolute value of “-544.7” that is returned by the abs() function.

The CEILING() function takes the value “544.7” as the argument and gives back the value “545”.

SELECT CEILING(abs( -544.7 ));

Now the output is:

545

Summary:

In this context, we have learned how the function is applied to return the smallest integer value that is greater than or equal to that mentioned number.


Related Topics

MySQL RIGHT JOIN

MySQL right join links two tables with each other. The left table column connects with the complete right side table. Each row of the right table tries to connect with...

4 minutes read.

MySQL LOG10() function

In this context, we will learn how we can use the MySQL LOG10() function with proper syntax and good examples. Introduction of MySQL LOG10() function To evaluate the natural logarithmic value of...

2 minutes read.

MySQL Table Query

MySQL table query A database stored a lot of data and divided them into different relations known as tables. Each database can contain more than one table. These tables are created...

7 minutes read.

MySQL QUARTER() function

In this context, we will learn how we can use the MySQL QUARTER() function with proper syntax and good examples. Introduction of MySQL QUARTER() function The QUARTER() function in MySQL returns the...

3 minutes read.

MySQL vs SQL

What is MySQL? The open-source MySQL relational database management system is a vital software component for web-based applications. As the data is saved and sent over the internet, databases and related...

6 minutes read.

MySQL Tutorial

In this tutorial, you will get information about the MySQL management system. This tutorial will cover the basic and advanced level MySQL concepts with examples that will help you become...

5 minutes read.

MySQL ROUND() function

In this context, we will learn how we can use the MySQL ROUND() function with proper syntax and good examples. Introduction of MySQL ROUND() function The ROUND() function in MySQL is used...

3 minutes read.

MySQL IF statement

The IF statement shows the true condition of the control flow function. The first condition is necessary to fulfill the requirement. The other condition is optional in the "IF" statement....

3 minutes read.

MySQL SUM function

The SUM() function displays the total addition of the table values. It supports the arithmetic operation of the column values. This function does not return a null value. Here, the...

5 minutes read.

MySQL function

MySQL function is a piece of program to perform some specific task. Here we pass a parameter and then return a single value. MySQL function mainly supports string, numeric, conditional,...

9 minutes read.

MySQL CEIL() function

In this context, we will learn how we can use the MySQL CEIL () function with proper syntax and good examples. Introduction of MySQL CEIL() function Input is taken by the CEIL()...

3 minutes read.

MySQL Descending Index

Descending Index It is a type of index that stores key values in descending order. This query improves the performance of an index query. MySQL system displays the index as per...

3 minutes read.

MySQL DATE_ADD() function

In this context, we will learn how we can use the MySQL DATE_ADD() function with proper syntax and good examples. Introduction of MySQL DATE_ADD() function In MySQL, the DATE_ADD() function is used...

3 minutes read.

MySQL LENGTH() Function

In this context, we will learn how we can use the MySQL LENGTH() function with proper syntax and good examples. Introduction of MySQL LENGTH() function This function in MySQL is used to...

2 minutes read.

MySQL String Function

The string function is used to maintain and operate string values. This function modifies the string data as per function. We can do the concatenation, conversion, removal and replacing the...

4 minutes read.

MySQL RAND() function

In this context, we will learn how we can use the MySQL RAND() function with proper syntax and good examples. Introduction of MySQL RAND() function Basically, in MySQL the RAND() function is...

3 minutes read.

MySQL database queries

MySQL database queries Database queries help to create, use, show and, delete the database. A Database is a collection of several tables and data. The database uses SQL language to perform...

3 minutes read.

MySQL Features

Features of MySQL MySQL is a relational database management system (RDBMS): It is a collection of many programs and makes relations with many other programs. Easy to use MySQL database: MySQL...

2 minutes read.

MySQL HEX() function

In this context, we will learn how we can use the MySQL HEX() function with proper syntax and good examples. Introduction of MySQL HEX() function For returning an equivalent hexadecimal string value...

3 minutes read.

MySQL FLOOR() function

In this context, we will learn how we can use the MySQL FLOOR() function with proper syntaxes and examples. Introduction of MySQL Floor() function: FLOOR() function in MySQL is used to return...

3 minutes read.