decimals oracle sql

0

I have a question, I have in database a data of type number(5,2) but I have values with

1
1.1
3.18

The question is, in the query I can have the zeros added to the right so that the data comes out

1.00
1.10
3.18

the base is oracle.

    
asked by mazhivo 10.03.2017 в 00:46
source

1 answer

1

Someone asked a very similar question here and I think the answer I left there can also be used.

As I can not mark this question as a duplicate of that one, I will include the details in this answer again:

What I understand is that you are looking for a way to format numbers so that you always have 2 digits after the decimal point.

This can be done with the TO_CHAR function specifying the desired format:

to_char(num, 'fm9990.00')

Demo

  • the fm is to eliminate leftover spaces.
  • 9 specify optional digits.
  • 0 specify digits that should appear.

If the numbers can have more digits than the thousands, simply add more 9 s to the left.

Example:

to_char(num, 'fm9999999990.00')
    
answered by 10.03.2017 / 00:59
source