Oracle
 sql >> Database >  >> RDS >> Oracle

Rimuovi lo zero decimale finale

I tuoi campioni mostrano due formati diversi:uno per i numeri decimali e uno diverso per i numeri interi.

with sampledata as
  (select 0.23 as rowa from dual
union all select 0.2350 from dual
union all select 0.1000 from dual
union all select 1.250 from dual
union all select 1200 from dual
union all select 1.300 from dual
 )
select TO_CHAR(rowa
              ,CASE WHEN rowa = TRUNC(rowa)
               then 'fm999999999999999990'
               else 'fm999999999999999990D999'
               end) as rowa
from sampledata;

ROWA
=====
0.23
0.235
0.1
1.25
1200
1.3