Getting the ceil value of a number in SQLite Getting the ceil value of a number in SQLite sqlite sqlite

Getting the ceil value of a number in SQLite


How about this?

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


This will give you the same answer more elegantly:

SELECT CAST(x+1-1e-n AS INT);

(assuming you won't have a precision greater than n decimal points)


using php you can easily:

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