CEILING 函数 SQL 服务器
CEILING Function SQL server
我期待以下 SQL 查询 return 1
SELECT CEILING(2/10)
但是它 return 是 0。有没有办法从 SQL 中得到 1?
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.
您至少需要将一个操作数更改为DECIMAL/FLOAT
:
SELECT CEILING(2.0/10)
--
SELECT CEILING(CAST(2 AS DECIMAL(10,2))/10)
我期待以下 SQL 查询 return 1
SELECT CEILING(2/10)
但是它 return 是 0。有没有办法从 SQL 中得到 1?
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.
您至少需要将一个操作数更改为DECIMAL/FLOAT
:
SELECT CEILING(2.0/10)
--
SELECT CEILING(CAST(2 AS DECIMAL(10,2))/10)