| |
|
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.
|
 |

06-29-09, 09:35
|
|
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
|
|

06-29-09, 10:20
|
|
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"
|
|

06-29-09, 10:41
|
|
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?
|
|

06-29-09, 10:51
|
|
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.
|
|

06-29-09, 18:37
|
|
Registered User
|
|
Join Date: Jul 2003
Posts: 2,292
|
|
PHP Code:
jmagnus@prod01> select 100000 thenumber from dual;
THENUMBER
----------
100000
jmagnus@prod01> col thenumber format 999,999
jmagnus@prod01> /
THENUMBER
---------
100,000
__________________
- The_Duck
you can lead someone to something but they will never learn anything ...
|
|

06-30-09, 09:34
|
|
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?
|
|

06-30-09, 15:00
|
|
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.
|
|

06-30-09, 15:11
|
|
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 ...
|
|

07-01-09, 05:39
|
|
Registered User
|
|
Join Date: Aug 2008
Posts: 298
|
|
|
Thank you
Thanks guys. I have what I want 
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|