473,383 Members | 1,840 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,383 software developers and data experts.

How is better to get SUM OF COUNTs

Hi
I am looking for some better solutions to do this action:
I want to get the sum of some Counts which are grouped.
It means that I want to calculate the sum of a column of some records that this column is made with the COUNT aggregate function:


SELECT SUM(CITY_COUNT)
FROM (SELECT COUNT(CITY) CITY_COUNT
FROM MYTABLE
GROUP BY CREATION_DATE)
But the number of records are too much, so this solution may not have a good performance.

what's your idea?
regards
Nov 21 '06 #1
2 1985
sashi
1,754 Expert 1GB
Hi
I am looking for some better solutions to do this action:
I want to get the sum of some Counts which are grouped.
It means that I want to calculate the sum of a column of some records that this column is made with the COUNT aggregate function:


SELECT SUM(CITY_COUNT)
FROM (SELECT COUNT(CITY) CITY_COUNT
FROM MYTABLE
GROUP BY CREATION_DATE)
But the number of records are too much, so this solution may not have a good performance.

what's your idea?
regards

Hi there,

How long does this query take in total to execute? What's the size of this particular database? How many records are there in total? Please provide these details. Good luck & Take care.
Nov 21 '06 #2
willakawill
1,646 1GB
Hi
I am looking for some better solutions to do this action:
I want to get the sum of some Counts which are grouped.
It means that I want to calculate the sum of a column of some records that this column is made with the COUNT aggregate function:


SELECT SUM(CITY_COUNT)
FROM (SELECT COUNT(CITY) CITY_COUNT
FROM MYTABLE
GROUP BY CREATION_DATE)
But the number of records are too much, so this solution may not have a good performance.

what's your idea?
regards
Hi. This might seem silly to you if you have some other reason for structuring your query this way. On the face of it your query is doing this:
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(CITY) AS TotalCities
  2. FROM MYTABLE
  3.  
Nov 21 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ina | last post by:
I want to walk a folder structor and group all the files by extention. Here is the code I put together is there a better way of doing this? <code> import os folderKey = "Folders" dicExt = {}...
1
by: Jeff Uchtman | last post by:
Query in ASP against a MS SQL DB. <% Dim Sql Dim Conn Dim totalCount Dim rsCount Dim rsACount Dim PetACount Dim rsBCount
0
by: Andres | last post by:
Hi, i have this questions: 1 - How can i create user counts in Windows with C#? 2 - How can i set permissions for the counts with C#? 3 - How can i start an application with one of the created...
5
by: WertmanTheMad | last post by:
Ive been playing with this for a few days and thought I might thow it out for seggestions. I have Several Queries that need counts returned The Queries are Mutually Exclusive meaning whatever...
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
0
by: Anne Heddal | last post by:
I've always used Paradox due to the QBE Query system, but I suspect performance to be better with Access and want to convert. Thus I need to execute a query that I'm not sure how to format in...
1
by: RC | last post by:
It would be nice to have an editor or "source safe" that tracks changes and shows relationships between things like "If" and "End If". Anyone know of any other possibilities? I found one but I...
8
by: cppquester | last post by:
Hi Folks, I just had the following idea for opertor new and delete (I am sure I am not the first one, haven't seen it so far though): class A { std::vector< intsomeData;
3
by: Wildster | last post by:
Hi, How can you count x and y as seperate counts from the same field? i.e. A table has the field Gender and I want to have one count which counts the number of records with 'male' as the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.