Skip to content Skip to sidebar Skip to footer

How To Expand Decimal Places Of A Number To A Minimum In Oracle Plsql?

I cant figure out how to select the following: 123 -> 123.00000 123.12 -> 123.12000 123.123456 -> 123.123456 I would like to expand the number of decimal place

Solution 1:

You could use the following:

SQL>SELECT X, to_char(X, 'fm99999999.00000999')
  2FROM (SELECT123 X FROM dual UNIONALL3SELECT123.12FROM dual UNIONALL4SELECT123.123456FROM dual);

         X TO_CHAR(X,'FM99999999.00000999
---------- ------------------------------
       123 123.00000
    123.12 123.12000
123.123456 123.123456

Solution 2:

You need to convert it to a Varchar as follows:

SELECT to_char(123, '9999.99999') from dual;

Solution 3:

if you want to FORMAT the data, you have to use the to_char function. in numeric values trailing zeroes are truncated (they are irrelevant).

Post a Comment for "How To Expand Decimal Places Of A Number To A Minimum In Oracle Plsql?"