The CEIL()
function returns the nearest smallest integer that is greater than or equal to a number. Some database servers use the CEILING()
function, which is equivalent to the CEIL()
function. Figure 1 shows the mathematical representation of the CEIL()
function.
CEIL(number)
CEILING(number)
This function requires a number or a numeric value as a parameter.
CEIL()
returns the nearest smallest integer that is greater than or equal to a number sent as a parameter.
/*example showing how to use CEIL(X)*/-- positive numberselect CEIL(3.13);-- negative numberselect CEIL(-2.78);
Now, consider another example in which the teacher wants to round up the marks of the students.
The figure below shows the student table, followed by the query that rounds up the marks.
Student ID | Student Name | Student Marks |
1 | David | 22.5 |
2 | Luiss | 20.14 |
3 | Harvey | 15.3 |
4 | Lucy | 25 |
5 | Andrew | 10.7 |
/*Query returns the marks of all the students afterapplying CEIL() */select studentID, studentName, CEIL(studentMarks) as studentMarksfrom Students