Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cant have aggregate function in expression?

Status
Not open for further replies.

jahlmer

Technical User
Aug 23, 2000
143
US
Help w/ Access 97 Query

I need the average of a count. (Actually, I don't even know what I need really). I have a timestamp for calls. I need to break them down into a daily count, then average that.

I tried

SELECT avg(Count(*)) AS Expr1
FROM tblNewCalls
WHERE (((tblNewCalls.Date)>=Date()-7));

But of course, no go. I'm new to SQL and VBA but know access pretty good otherwise...

Any suggestions on how to accomplish this will be greatly appreciated. Should I use a subquery for this?

Thanks.
 
SELECT Count(*)/7 AS avgeragcalls
FROM tblNewCalls
WHERE (((tblNewCalls.Date)>=Date()-7));

 
Wow, what does the /7 do? This certainly seems like it works, but I still don't know how. An explaination would help me keep from having to post these dumb questions.

Thanks for the post.
 
SELECT Count(*)/7 AS avgeragcalls

select count(*) returns the count

/7 divides the count by 7. Since you were returning 7 days worth of records

AS avgeragcalls assigns an alias to the field
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top