Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Formatting number using TO_CHAR

IniyavanNov 27 2009 — edited Nov 27 2009
Hi all,

I need to format number as following:

--------------------------------------------
123.456 => 123.456
0.12 => 0.12
123 => 123
-123.456 => 123.456
-0.12 => 0.12
-123 => 123
------------------------------------------------

I need a single query to perform this. The problem is with 0.12. Oracle returns .12, not 0.12. If I use TO_CHAR(0.12,'0.99'), then other numbers get affected.

There should not be leading/trailling zeros.

Thank in advance.

Edited by: Iniyavan on Nov 27, 2009 10:33 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2009
Added on Nov 27 2009
4 comments
578 views