DECLARE @a int;
DECLARE @b int;
SET @a = 9;
SET @b = 2;
SELECT CEILING (@a/@b);
It is returning as 4 instead of 5. Why?
Edit: I would like to get next smallest integer if the quotient is not whole number.
Try:
SELECT CEILING (@a/CAST(@b AS float))
And consider NULLIF(@b,0)
too, to avoid a Division By Zero error.