MySQL CEIL() Function

The CEIL() function in MySQL rounds a number *up* to the nearest integer. This means it always increases the number to the next whole number, discarding any fractional part.



CEIL(): Definition and Usage

CEIL() is very useful when you need to work with whole numbers and want to make sure that any fractional part of a number is always rounded upwards. This is often necessary in situations where you need to perform calculations based on the next highest integer.

Syntax

Syntax

CEIL(number)
      

Parameter Values

Parameter Description
number The number you want to round up. This is required and must be a numeric value.

Equivalent Function: CEILING()

The CEILING() function is identical to CEIL(); both perform the same upward rounding.

Examples

Rounding Up a Decimal Number

This example rounds the number 25.75 up to 26.

Syntax

SELECT CEIL(25.75);
      
Output

26
      

Rounding Up a Whole Number

If the input number is already a whole number, CEIL() returns the same number.

Syntax

SELECT CEIL(25);
      
Output

25