SQL 服务器 - 如何向上或向下舍入小数?

SQL Server - How to round up or down decimals?

我希望能够向上或向下舍入 10.823。预期结果:

rounding down = 10.82
rounding up = 10.83

知道round(10.823, 2)才四舍五入。如何取整?

你是对的,round 是这项工作的错误工具。相反,您应该使用 floor and ceiling。不幸的是,它们没有像 round 这样的精度参数,因此您必须使用除法和乘法来模拟它:

SELECT FLOOR(value * 100) / 100 AS rounded_down,
       CEILING(value * 100) / 100 AS rounded_up
FROM   mytable