By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,197 Members | 972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,197 IT Pros & Developers. It's quick & easy.

Calculating SUM and COUNT in one statement

P: n/a
Hi,

I need to retrieve
1. a total
SELECT SUM(COL1) FROM SOME_TABLE
2. most frequent values
SELECT COL1, COUNT(*) FROM SOME_TABLE GROUP BY COL1

I want to scan the table only once, so I was trying to accomplish both
tasks in one statement. It's Oracle 9i
Any ideas?
TIA
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
fo************@yahoo.com (Ford Desperado) wrote in message news:<e9**************************@posting.google. com>...
Hi,

I need to retrieve
1. a total
SELECT SUM(COL1) FROM SOME_TABLE
2. most frequent values
SELECT COL1, COUNT(*) FROM SOME_TABLE GROUP BY COL1

I want to scan the table only once, so I was trying to accomplish both
tasks in one statement. It's Oracle 9i
Any ideas?
TIA


How about:

select col1,sum(col1),count(*)
from some table
group by col1
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.