2013-09-21 50 views
0

所以我使用了一個公式,然後我在最後改變了代碼的別名。我如何捨棄這個別名?我試圖在整個方程上使用循環函數,但無濟於事,我得到了錯誤#1583。MySQL 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值進行四捨五入。

+0

你能證明得到了錯誤,而不是工作版本的版本? – Barmar

回答

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; 
+0

你是我的救星!謝謝! –