473,406 Members | 2,713 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,406 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 22440
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.