to_char(num,
'fm999999990.999999999'
)to_char(num,
'fm999999990.000000000'
)總之進行0,9的切換嘗試組合就行了
如果有時出現 0.% 後面就沒有了的情況
可以用replace函式 replace('.%','.00%')
較為通用的,格式化成 0.00%格式的方法
replace(to_char(d.qxxcl*100,'fm999999990.999999999') || '%','.%','.00%')
解決方案如下
(1)[sql]view plain
copy
sql>
select
to_nmber(to_char(0.99))
from
dual;
to_number(to_char(0.99))
------------------------
0.99
sql> select
to_char(num,
'fm999999990.999999999'
) from
ml_test;
to_char(num,'fm999999990.99999
------------------------------
0.42124
0.421246543
65432.42124324
4.62124
(2)使用case when 或 decode函式,取第一位是否為".", 補0 ,就ok了
[sql]view plain
copy
sql>
select
to_char(num,
'999999999.999999999'
) from
ml_test;
to_char(num,'999999999.9999999
------------------------------
.421240000
.421246543
65432.421243240
4.621240000
sql> select
to_char(num)
from
ml_test;
to_char(num)
----------------------------------------
.42124
.4212465434
65432.42124324
4.62124
sql> select
to_char(0.99)
from
dual;
to_char(0.99)
-------------
.99
C 小數點格式化
1.tostring 方法 double d 12345678.2334 console.writeline d.tostring f2 1234.23 console.writeline d.tostring 00 12,345,678.23 2.math.round 方法 math.round ...
C 小數點格式化
1.tostring 方法 double d 12345678.2334 console.writeline d.tostring f2 console.writeline d.tostring 00 12,345,678.23 2.math.round 方法 math.round 3.44,1 r...
C 小數點格式化
1.tostring 方法 double d 12345678.2334 console.writeline d.tostring f2 console.writeline d.tostring 00 12,345,678.23 2.math.round 方法 math.round 3.44,1 r...