0

所以我使用了一个等式,然后我在最后更改了代码的别名。我如何舍入该别名?我尝试在整个方程上使用 round 函数,但无济于事,我得到了错误 #1583。

这是代码:

select product_name, list_price, discount_percent,
      (.01 * discount_percent) * list_price as ROUND(discount_amount,2),
      list_price - (.01 * discount_percent) * list_price  as net_price
from products;

我希望将 net_price 和 discount_amount 值四舍五入。

4

1 回答 1

0

尝试:

select product_name, list_price, discount_percent,
      ROUND( (.01 * discount_percent) * list_price, 2 ) as discount_amount,
      ROUND( list_price - (.01 * discount_percent) * list_price, 2 ) as net_price
from products;
于 2013-09-22T07:58:35.840 回答