I was expecting the following SQL Query to return 1
SELECT CEILING(2/10)
However it returns 0. Is there any way to get 1 from that SQL?
I was expecting the following SQL Query to return 1
SELECT CEILING(2/10)
However it returns 0. Is there any way to get 1 from that SQL?
Integer division: 2/10 => 0
If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated.
You need to change at least one operand to DECIMAL/FLOAT
:
SELECT CEILING(2.0/10)
--
SELECT CEILING(CAST(2 AS DECIMAL(10,2))/10)