(Oracle SQL) how to add .00

I have an integer, for example 3. Now I want them to change to 3.00, what function should I use?

I can only round from 3.00 to 3, but I don’t know how to do this in reverse order.

+4
source share
3 answers

The numbers do not have a built-in format (although they may be limited by a certain accuracy and scaling), and to your client how it displays the number. To display a number in a specific format, you can convert it to a formatted string using the functionTO_CHAR :

select to_char(3, '999990D00') from dual;

TO_CHAR(3,
----------
      3.00

Numeric format elements are also listed in the documentation .

D00, ( NLS), - , , , . 0 , , , ; .3 0.30, .

9, . , , .

+2

TO_CHAR

SELECT to_char(integerfield, '999990D00') 
FROM yourtable;

SELECT to_char(intfield, '9999.99') 
FROM yourtable;

SQL FIDDLE: http://sqlfiddle.com/#!4/81a4b/5/0

0

. , , , .

:

  • numformat
  • use TO_CHAR for the number with the desired format.

In SQL * Plus :

SQL> set numformat 9999D99
SQL> SELECT TO_NUMBER( TO_CHAR(3,'9999D99')) num FROM dual;

     NUM
--------
    3.00

SQL>
0
source

All Articles