473,395 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calculating SUM and COUNT in one statement

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
1 22437
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
In ASP page, if we want to retrive the number of rows in database: should we use recordset object? Since this is not update, insert, delete, or select statement sqlStmt = "SELECT COUNT(*) from...
0
by: Fatt Shin | last post by:
Hi, I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB Connector 3.51. I'm facing a problem where whenever I issue a SELECT COUNT(*) statement from PowerBuilder, I always get SQL...
2
by: bsder | last post by:
Hi, If I want to select a result that based on the value of count (eg. count(*) > 5), how can I write a sql to do that? eg. select count(*)>5 from Flight where OperationType = "Departure"...
5
by: Karl Irvin | last post by:
In VBA, how do you see the results of an sql count statement like the following ? Select Count (*) as Total from tblCustomer Result = DoCmd.RunSql("Select Count (*) as Total from...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
6
by: Lawrence 007 | last post by:
Hi, I need to count the number of rows in my Item table. The following statement gives me the number i.e. 200. Select Count(*) As Counter From Item Group By Id How can I number each...
1
by: BeeBop | last post by:
Having an issue with the @Count parameter in the following and I'm rather new to this so I may have missed something: Create Procedure AAA As Declare Customer Cursor Fast_Forward For Select...
1
by: Proogeren | last post by:
Hello I was wondering how I can make query on 3 tables and sort on a count statement E.g If I have one table Person I have one table Movie I have one table Downloaded If a person download...
1
by: preeti13 | last post by:
i have a store procedure i am trying to count the records but getting the probelm with this please if any one know about this help me my store procedure is like this CREATE proc...
4
by: whatsuppussycat | last post by:
I want to be able to SUM the values returned using the TOP 5 and COUNt statements. So far I've tried from many angles and can't get it to work, very frustrating! Here is my code: SELECT TOP 5...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.