CEIL()

Description

The CEIL(X) function returns the smallest integer value not less than X.

Syntax

1. > CEIL(X)

Arguments

Arguments Description
X Required. Any numeric data type supported now.

For exact-value numeric arguments, the return value has an exact-value numeric type. For floating-point arguments, the return value has a floating-point type.

Examples

1. drop table if exists t1;
2. create table t1(a int ,b float);
3. insert into t1 values(1,0.5);
4. insert into t1 values(2,0.499);
5. insert into t1 values(3,0.501);
6. insert into t1 values(4,20.5);
7. insert into t1 values(5,20.499);
8. insert into t1 values(6,13.500);
9. insert into t1 values(7,-0.500);
10. insert into t1 values(8,-0.499);
11. insert into t1 values(9,-0.501);
12. insert into t1 values(10,-20.499);
13. insert into t1 values(11,-20.500);
14. insert into t1 values(12,-13.500);

16. mysql> select a,ceil(b) from t1;
17. +------+---------+
18. | a    | ceil(b) |
19. +------+---------+
20. |    1 |       1 |
21. |    2 |       1 |
22. |    3 |       1 |
23. |    4 |      21 |
24. |    5 |      21 |
25. |    6 |      14 |
26. |    7 |      -0 |
27. |    8 |      -0 |
28. |    9 |      -0 |
29. |   10 |     -20 |
30. |   11 |     -20 |
31. |   12 |     -13 |
32. +------+---------+
33. 12 rows in set (0.01 sec)

35. mysql> select sum(ceil(b)) from t1;
36. +--------------+
37. | sum(ceil(b)) |
38. +--------------+
39. |            6 |
40. +--------------+
41. 1 row in set (0.01 sec)