Getting ceil value for number in SQLite

So, I see this question , there is a good answer, but I want to round, no matter what, instead of rounding, no matter what. Adding 1 to it before cast int will not work, because it will be "round" 5.0 in 6.0, for example.

So how do I implement ceil in SQLite?

+4
source share
3 answers

How about this?

 select (case when x = cast(x as int) then cast(x as int) else 1 + cast(x as int) end) 
+5
source

This will give you the same answer more elegantly:

 SELECT CAST(x + 0.5 AS INT) 
+6
source

using php you can easily:

 $db->createFunction('ceil', 'ceil', 1); $db->createFunction('floor', 'floor', 1); select ceil(\`column`) from table; 
-1
source

All Articles