Solved

pl/sql - commas, thousand separator

Posted on 2007-03-21
3
3,920 Views
Last Modified: 2013-12-19
Good morning,

Is there a way to format the results of a query so that commas (thousand separators) show up in the results.
 
For example in Visual basic you can use the format function but can I do this using PL/SQL so that no additional formatting would need to be done in VB?

Here is my query:
Select Null as Date1, Disputed, OverdueUnknown, Round((Disputed * 263 / 201407169.04),2) as DDSO,Round((OverdueUnknown * 263 / 201407169.04),2) As OUDSO From (SELECT Sum(DECODE(GPRECL.PROBLEM_ID, 0, 0, GPRECL.BALANCE)) AS Disputed, Sum(DECODE( GPRECL.PROBLEM_ID, 0, GPRECL.BALANCE, 0)) AS OverdueUnknown FROM GPCOMP10.GPRECL GPRECL  WHERE GPRECL.BALANCE > 0 AND GPRECL.DUEDATE <= TO_DATE(SYSDATE))
0
Comment
Question by:lorincha
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 18764398
sample usage of to_char:
select to_char(234.2342340, '999,999,990.000') from dual    

in your case:
Select Null as Date1, Disputed, OverdueUnknown
, to_char(Round((Disputed * 263 / 201407169.04),2) , '999,999,999,990.00') as DDSO
, to_char(Round((OverdueUnknown * 263 / 201407169.04),2) , '999,999,999,990.00') As OUDSO From (SELECT Sum(DECODE(GPRECL.PROBLEM_ID, 0, 0, GPRECL.BALANCE)) AS Disputed, Sum(DECODE( GPRECL.PROBLEM_ID, 0, GPRECL.BALANCE, 0)) AS OverdueUnknown FROM GPCOMP10.GPRECL GPRECL  WHERE GPRECL.BALANCE > 0 AND GPRECL.DUEDATE <= TO_DATE(SYSDATE))
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18764407
note:
TO_DATE(SYSDATE))
is nonsense. SYSDATE IS already date, so remove that call to TO_DATE.
if you want to get the date part only, use the TRUNC() function instead
0
 

Author Comment

by:lorincha
ID: 18764561
Hi Angellll,

If you don't mind me asking....

TO_CHAR(OverDueUnknown, '999,999.99')

Say for instance that the number grows to the billions, in that case if I used the example above the results shows ######## in the result set.

Do you just need to put as many 999s as possible to predict the largest # possible?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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 how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

773 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