Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Averages of sums in a single query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-12-08 : 12:18:17
Ann writes "I have a SQL Server table that contains survey results. I can use the following query to return the number of surveys submitted each day:

SELECT COUNT(*) AS howmany
FROM Survey2
GROUP BY MONTH(SurveyDate), day(SurveyDate)

What I really want is to know the daily average. I can do this by creating a view called daily_totals based on the above query, then running this query against the view:

SELECT AVG(howmany)
FROM daily_totals

Is there some way to do this all in one query? It seems so simplistic, but I can't figure out how to do it.

Thanks."
   

- Advertisement -