RecipeDan
asked on
Count Data then Sum Rows
Hello:
I have this SQL Statement: SELECT Count(FinalData) AS Total FROM Data
It displays the results in a row like this:
34
78
44
90
35
The results are correct. How can I sum the results after I count them?
I have this SQL Statement: SELECT Count(FinalData) AS Total FROM Data
It displays the results in a row like this:
34
78
44
90
35
The results are correct. How can I sum the results after I count them?
SELECT sum(Count(FinalData)) AS Total FROM Data
Gallitin -> Your query will yield the following error message -
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
The count(finaldata) in the original query is resulting in multiple rows because there is a grouped field which has not been indicated in the question. Otherwise a mere count(finaldata) should suffice..
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
The count(finaldata) in the original query is resulting in multiple rows because there is a grouped field which has not been indicated in the question. Otherwise a mere count(finaldata) should suffice..
I just tested in query analyzer a minute ago against a tabel of mine, I must have done something different then
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SELECT COUNT(FINALDATA) AS Total
FROM Data
COMPUTE SUM(COUNT(FINALDATA))
This gives me the same result
34
78
44
90
35
FROM Data
COMPUTE SUM(COUNT(FINALDATA))
This gives me the same result
34
78
44
90
35
What is your expected result? Are you looking for this? Do yu have GROUP BY clause in your original query?
SELECT SUM(Total) FROM (SELECT COUNT(FINALDATA) AS Total FROM Data ) T1
SELECT SUM(Total) FROM (SELECT COUNT(FINALDATA) AS Total FROM Data ) T1
COMPUTE SUM(COUNT(FINALDATA))