首先,你这个需求有点怪,居然不考虑小数点的位置,一律输入12位?是否应该是这样:如果总位数(含小数点)大于12,则显示12位。如果总位数(含小数点)小于12,则显示当前的本色。
with t as (select 12.1357698231 as a from dual)
select to_char(round(a,11-length(round(a))),'fm999999999990.9999999999') AS result from t;
RESULT
------------------------------------------------------------------------
12.135769823
with t as (select 54312.1354 as a from dual)
select to_char(round(a,11-length(round(a))),'fm999999999990.9999999999') AS result from t;
RESULT
------------------------------------------------------------------------
54312.1354
with t as (select 0.13 as a from dual)
select to_char(round(a,11-length(round(a))),'fm999999999990.9999999999') AS result from t;
RESULT
------------------------------------------------------------------------
0.13