执行sql:select t.amount,round(z.UNITPRICE*t.amount,2) as total
from znls_instore_order_item t
left join znls_store z on t.storeid=z.storeid
计算数值时,由于UNITPRICE 这个字段为vachar类型,结果 44.325 round() 取2时 没有进行四舍五入 例如4.5,当字段类型为varchar或double类型时,使用round函数,可能不会进行四舍五入,结果为2,而decimal则进位正常。
解决方法:
在改字段后面 加一个不会影响数值的值
select t.amount,round((z.UNITPRICE+0.000001)*t.amount,2) as total
from znls_instore_order_item t
left join znls_store z on t.storeid=z.storeid