按百分比提高价格,结果四舍五入

问题描述 投票:1回答:1

我正在使用Microsoft SQL Server,我需要将my_table中的所有价格更新4%

我在stackoverflow上找到了以前的答案,我知道正确的方法应该是:

UPDATE my_table SET price = (price * 1.4)

但我的客户希望价格四舍五入。因此,如果结果为90,4则必须为90,如果为90.7,则必须为91。

可能吗?

sql sql-server
1个回答
4
投票

使用ROUND()

UPDATE my_table
    SET price = ROUND(price * 1.4, 0);
© www.soinside.com 2019 - 2024. All rights reserved.