?
Solved

How to format a negative number in oracle to show one decimal only and negative numbers should be displayed in  round brackets ()

Posted on 2008-11-19
8
Medium Priority
?
4,464 Views
Last Modified: 2013-12-19
How to format a negative number in oracle to show one decimal only and negative numbers should be displayed in  round brackets ()?

This query: select to_char(-13214.2973,'999,999.0PR') from dual
Gives me this:  <13,214.3>
I want this:  (13,214.3)

Any Suggestions?

Thank You.
0
Comment
Question by:Faheem Shaikh
8 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 1000 total points
ID: 22996975
unfortunately  the PR format model is hardcoded to use angle brackes <>, so you'll have to convert them yourself.  Translate provides an easy way to do both ends of the brackets in one command

select translate(to_char(-13214.2973,'999,999.0PR'),'<>','()') from dual
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 1000 total points
ID: 22996977
select translate(to_char(-13214.2973,'999,999.0PR'),'<>','()') from dual;
0
 
LVL 32

Expert Comment

by:awking00
ID: 22996982
As Maxwell Smart would say, "Missed by just this much!"
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 14

Expert Comment

by:ajexpert
ID: 22996994
Hope this helps
 select replace(translate(to_char(-13214.2973,'999,999.0PR'),'<','('), '>', ')') from dual

Open in new window

0
 
LVL 74

Expert Comment

by:sdstuber
ID: 22997138
I'd call it a tie.  :)

hopefully the asker will give a split between us
0
 
LVL 8

Author Comment

by:Faheem Shaikh
ID: 22997265
Guys, that was fast......and it is a split.
Thank You.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 22997370
glad we could help
0
 
LVL 32

Expert Comment

by:awking00
ID: 22997854
Thanks to both of you for being so kind :-)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question