×

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 Character Length Function

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

2 minutes read.

MySQL ISNULL function

This function is used to check the null value in table data. It returns the result in a Boolean form. If table data is null, then the output becomes 1....

2 minutes read.

MySQL MIN function

The MIN() function determines the minimum or lowest value of the data set. This function works on numerical data type values. If the table displays zero value, then the row...

4 minutes read.

MySQL logical conditions

MySQL logical conditions Introduction MySQL handles data with clauses, operators, and conditions. The logical condition is used to compare information and returns the required output. This condition applies logic to MySQL expressions...

7 minutes read.

MySQL Invisible Index

Invisible Index MySQL index decides an option to the availability of the index for the query optimizer. This index shows the visible and invisible options to displays the index column in...

3 minutes read.

MySQL Date and Time function

The date function displays day, year, month, time, and current date. It shows the date and time as per the requirement of the applications. The data either store on the...

8 minutes read.

MySQL Environmental Setup

The MySQL Environmental Setup MySQL is free, open-source, and cross-platform software, which can be downloaded from its official website. MySQL management system installs on Linux, macOS, and windows. MySQL requires a framework...

6 minutes read.

MySQL LOAD_FILE() function

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

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 Unique index

It helps to maintain data integrity to enforce the uniqueness of values in one or more columns. We can create more than one UNIQUE index in a single table, which...

3 minutes read.

MySQL COALESCE function

This statement displays the first non-null value of the table data. The COALESCE function returns a null value when all values of the table are null or do not find...

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 Advance table Query

MySQL Advance table Query The table is created by index, rows, and columns in the MySQL database. The user saves their information in matrix format. The database requires a query to...

14 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 LOG2() function

In this context, we will learn how we can use the MySQL LOG2() function to calculate the Logarithm of a specific number with base 2 with proper syntax and examples. Introduction...

2 minutes read.

MySQL Drop Index

Sometimes we have an index that is not required in data operations. In that case, we can use this statement to remove an existing index from the table. We can...

4 minutes read.

MySQL LEAST function

This statement displays the smallest value of the table. The LEAST function returns a null value when the table contains a null value. If the table contains all numerical values,...

2 minutes read.

MySQL Prefix index

Prefix index This index query creates an index column in the string or character column. MySQL system can create multiple indexes in the table. It will create in a table as...

3 minutes read.

MySQL INSERT() Function

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

2 minutes read.