Solved

pl/sql - commas, thousand separator

Posted on 2007-03-21
3
3,864 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
Comment Utility
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]
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

Suggested Solutions

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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.
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.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now