MariaDB CEILING: Round numbers up to an integer
MariaDB’s CEILING(x) returns the smallest integer greater than or equal to x. Rounding up moves toward larger values on the number line, so 1.5 becomes 2 and -1.5 becomes -1.
Syntax and basic results
Pass a number, a numeric column or a calculation as x. Whole numbers stay the same, and NULL returns NULL. Run the query below without a table. The 1 in the last column means that IS NULL evaluates to true.
SELECT CEILING(1.0) AS positive_integer,
CEILING(1.5) AS positive_fraction,
CEILING(-1.0) AS negative_integer,
CEILING(-1.5) AS negative_fraction,
CEILING(NULL) IS NULL AS null_stays_null;
1 | 2 | -1 | -1 | 1
How CEIL, FLOOR and ROUND compare
CEIL(x) is an alias for CEILING(x). FLOOR(x) returns the largest integer less than or equal to x, and ROUND(x) with one argument rounds to the nearest integer. For example, -1.6 is closer to -2, while rounding it up gives -1.
SELECT CEIL(-1.6) AS ceil_value,
FLOOR(-1.6) AS floor_value,
ROUND(-1.6) AS round_value;
-1 | -2 | -2
Official FLOOR reference, Official ROUND reference
Calculating the number of pages
At 20 items per page, 41 items need three pages. Leftover items still need a page, so divide with / and apply CEILING() to the result.
SELECT CEILING(41 / 20) AS partial_page,
CEILING(40 / 20) AS exact_pages,
CEILING(0 / 20) AS no_pages;
3 | 2 | 0
In this example, 40 items fill exactly two pages and zero items give zero pages. Validate that the page size is a positive integer. Using DIV first drops the fractional part of the quotient, so the last page would be missing for 41 items.




