MySQL CEIL() Function: Round upward to an integer

CEIL() returns the smallest integer greater than or equal to the input, including when the input is negative.

CEIL(): Quick SQL Example

Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.

SELECT CEIL(4.21) AS ceiling_value;
ceiling_value
5
On this page — Show page sectionsHide page sections

More SQL Examples and Explanations

SELECT CEIL(5.94);   -- 6
SELECT CEIL(5.24);   -- 6
SELECT CEIL(-5.24);  -- -5
SELECT CEIL(-5.54);  -- -5
We can use MySQL ceil() function to get the smallest integer not less than the input value.

Same way we can use the floor function to get the highest integer which is lower than the input value.

We can use ceil function to our student table where we will calculate the average mark of the students.
SELECT AVG(mark) AS avg_mark FROM student;
Output = 74.6571 Now we can use ceil command like this.
SELECT CEIL(AVG(mark)) AS avg_mark FROM student;
Output = 75

How to Interpret the Result

CEIL(-4.21) is -4, not -5. Compare FLOOR() for rounding downward.

Common Question

Does CEIL() round to the nearest integer?
No. It always selects the smallest integer that is not less than the input.

Further Reading

All Math Functions FLOOR()

Related: ROUND()

More related tutorials: All math functions, AVG()

↑ Back to top




Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer