我在表中有一个值 0.0821,我想将它转换为 8.21。
我的 SQL 查询是 to_char(round(prdll_yr2.rate_chg_pct_qty *100 ),'9.99')
但它返回 8.00 而不是 8.21。
请您参考如下方法:
to_char(round(0.0821 *100,2 ),'9.99')
to_char(round(prdll_yr2.rate_chg_pct_qty *100,2),'9.99')
您缺少要在回合中显示的小数位数...它将 default to 0 if omitted
或者举个例子:
select to_char(round(0.0821 *100,2 ),'9.99') from dual;
结果:8.21
select to_char(round(0.0821 *100),'9.99') from dual;
结果:8.00
----------------------------提供新信息:---------------- --------------
to_char(round(0.0821 *100,2 ),'9,999.99')
调整 9,999.99 format等于数据库中允许的比例和精度。因此,如果您的值为 Numeric(9,5),这意味着 4 个前导数字后跟 5 个小数位。由于您要乘以 100,因此您可以得到的最大值是小数点前 6 位,因此格式 999,999.99 和第三位小数将是“四舍五入”




