• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

format the output of a query to two decimal points

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI

I have a column named 'Commision'. It is defined as Number(10,2).

But actual values dont have any decimal points means they have values like 1400
11000
like this. ButI want to get the output as 11000.00 ,1400.00 and if it is null I have to get .00.

Can anyone help me???

Thanks
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use trunc function to do same

for example

select trunc(14000.00) from dual

SHailesh
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to use both TO_CHAR and NVL (same as Coalesce) to do this.

TO_CHAR formats your number to include the decimal.

NVL gives your column a default value if it happens to be null.

SELECT to_char(nvl(your_column_here,0),99999.99)
FROM rbw_leg.clm_li a
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have to convert the number to a string in order to control the formatting in SQL (since the number 1400 and 1400.00 are identical as numbers). Something like


SELECT to_char( NVL( comission, 0 ), '9999999999.99' )
FROM dual



would probably do the trick.
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic