SQL如何四舍五入

alter table item disable trigger all
update item set sale_price = price
alter table item enable trigger all

sale_price 卖价
price 进价

如何在上面的语句把卖价四舍五入
如何把卖价四舍五入到小数点后1位

update item set sale_price = price 理解为卖价最终会等于进价了。
如果是要把卖价等于进价四舍五入,则
update item set sale_price = cast(round(price,1) as numeric(15,1))
如果不满足您的需求,请继续追问,在线解答。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-08-05
ROUND 函数,为四舍五入的, 下面是一个例子:

SQL> SELECT ROUND(1.56), ROUND(1.56,1), ROUND(12.34, -2) FROM dual;

ROUND(1.56) ROUND(1.56,1) ROUND(12.34,-2)
----------- ------------- ---------------
2 1.6 0

对于你的表来说,就是
UPDATE
item
SET
sale_price = ROUND( sale_price, 1)

卖价四舍五入到小数点后1位
第2个回答  2011-08-08
ex.

SELECT ROUND(2.532,1)