SQL Language (MOSC)

MOSC Banner

How to format number like this?

edited Nov 7, 2014 4:56AM in SQL Language (MOSC) 2 commentsAnswered ✓

Hi,

We need to format a number field in way to add commas and to show decimal values as they are.

The below returns unwanted result:

select to_char(123456789.6545,  '999,999,999,999.9999')  from DUAL ;      >      123,456,789.6545

select to_char(123456789.65,  '999,999,999,999.9999')  from DUAL ;        >        123,456,789.6500

select to_char(123456789.6545,  '999,999,999,999.9')  from DUAL ;        >           123,456,789.7

select to_char(123456789,  '999,999,999,999.9999')  from DUAL ;        >           123,456,789.0000

What we need is as below:

123456789   >   123,456,789

123456789.6   >   123,456,789.6

123456789.47   >   123,456,789.47

123456789.589   >   123,456,789.589


We don't want zeros to show after the decimal part and we don't want any rounding to take place.


Please suggest the format that should be taken to achieve the above.


Thank you,

Christine

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center