If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > inserting the thousand seperator (,) in the output of a query

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-09, 09:35
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
inserting the thousand seperator (,) in the output of a query

Hi

I have the following query but I would like to have the numbers appear with a ',' to make the numbers more readable.

I know this can be done in Excel (which is where it should be done anyway) but just wondering if this can also be done at the query level:

select datetime,
sum(orginating_count) "Org Tot",
sum(terminating_count) "Term Tot",
( sum(orginating_count)+sum(terminating_count) ) "SM Tot",
round( ( sum(orginating_count)+sum(terminating_count) ) / 3600, 2) AVE
from schema.table
where datetime between trunc(sysdate)-1 and trunc(sysdate)-1/24
and caption not in ('mar2','mar1','SMQ','SM','MQ')
group by datetime

I've tried using TO_CHAR,'999,999' which gives me what I want but only if I don't use SUM in the statement.

Would appreciate any advice.

Regards
Sheraz
Reply With Quote
  #2 (permalink)  
Old 06-29-09, 10:20
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,298
Quote:
Originally Posted by shajju
I've tried using TO_CHAR,'999,999' which gives me what I want but only if I don't use SUM in the statement.
This should work:
Code:
to_char(sum(orginating_count),'999,999') "Org Tot"
Reply With Quote
  #3 (permalink)  
Old 06-29-09, 10:41
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Thanks and also...

Thanks. Works a treat. Can I also ask how to use TO_CHAR in:

( sum(org_count)+sum(term_count) ) "SM Tot",

and

round( ( sum(org_count)+sum(term_count) ) / 3600, 2) avg_sm?
Reply With Quote
  #4 (permalink)  
Old 06-29-09, 10:51
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
I would like to thank you for your help. TO_CHAR has saved the day. Thank you very much.

Note: I would like to close this thread now.
Reply With Quote
  #5 (permalink)  
Old 06-29-09, 18:37
The_Duck The_Duck is offline
Registered User
 
Join Date: Jul 2003
Posts: 2,292
PHP Code:
jmagnus@prod01select 100000 thenumber from dual;

 
THENUMBER
----------
    
100000

jmagnus
@prod01col thenumber format 999,999
jmagnus
@prod01> /

THENUMBER
---------
  
100,000 
__________________
- The_Duck
you can lead someone to something but they will never learn anything ...
Reply With Quote
  #6 (permalink)  
Old 06-30-09, 09:34
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Thanks...

Thanks for all your replies.

Duck

The 'col thenumber format 999,999' works in sqlplus only right? Not in toad. Am I being very silly?

Also, I take it 999,999 doesn't take care of values greater than 999,999?
Reply With Quote
  #7 (permalink)  
Old 06-30-09, 15:00
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,591
No, it does not work in TOAD.

No, it doesn't take care of values greater than 999,999. But nothing stops you to set column format differently.
Reply With Quote
  #8 (permalink)  
Old 06-30-09, 15:11
The_Duck The_Duck is offline
Registered User
 
Join Date: Jul 2003
Posts: 2,292
TOAD you would go into SETTINGS and change the setting to display numeric values with commas. Considering you would export that to excel I really don't see an issue since excel can display numerics any way you want (unless you want to see the numbers in the cells with columns).

if you want larger format then change 999,999 to 999,999,999,999,999
__________________
- The_Duck
you can lead someone to something but they will never learn anything ...
Reply With Quote
  #9 (permalink)  
Old 07-01-09, 05:39
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Thank you

Thanks guys. I have what I want
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On