Home » SQL & PL/SQL » SQL & PL/SQL » need help with formatting a number (9i)
icon9.gif  need help with formatting a number [message #399373] Tue, 21 April 2009 19:46 Go to next message
umajava
Messages: 8
Registered: December 2008
Junior Member
I am using below code to format a number. I am trying the below query to support following output values

1. 126262.00 converted to 126,262 (This is working fine)
2. 126262.45 converted to 126,262.45 (This is working fine)
3. 126262.6 converted to 126,262.60 (This is not working as expected)

select
trim(rtrim(to_char('126262.6', 'FM9,999,999,999.99'), '.'))
from dual


Can anyone help me please?
Re: need help with formatting a number [message #399381 is a reply to message #399373] Tue, 21 April 2009 22:26 Go to previous messageGo to next message
danish_fsd@yahoo.com
Messages: 38
Registered: February 2008
Location: Pakistan
Member
Try following

SELECT TRIM(RTRIM(TO_CHAR('126262.6', 'FM9,999,999,999.90'), '.'))
FROM dual


Regards

Danish
Re: need help with formatting a number [message #399382 is a reply to message #399373] Tue, 21 April 2009 22:33 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
select
replace(to_char(126262.60, 'FM9,999,999,999.90'), '.00', NULL)
from dual;


Ross Leishman
Re: need help with formatting a number [message #399536 is a reply to message #399373] Wed, 22 April 2009 18:41 Go to previous messageGo to next message
dr.s.raghunathan
Messages: 540
Registered: February 2008
Senior Member
also try '999G999G999D99'
Re: need help with formatting a number [message #399560 is a reply to message #399536] Thu, 23 April 2009 00:39 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
dr.s.raghunathan wrote on Thu, 23 April 2009 01:41
also try '999G999G999D99'

Which will NOT give you 123,234.00, which was the original problem
Previous Topic: how to set 'sessions_per_user' ?
Next Topic: how to switch between oracle 10g & 11g on the same PC
Goto Forum:
  


Current Time: Sat Feb 08 16:38:27 CST 2025