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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible nested query/SUM/COUNT???

Status
Not open for further replies.

chris6976

Technical User
Mar 4, 2003
28
GB
I have the following query...(aided by this wonderful forum!)

SELECT Calls.User_ID, Calls.Call_Type, Calls.Status, Calls.Date_Time
FROM Calls
WHERE (((Calls.Date_Time) Between [Forms]![frmCallsQuery]![Text1].[Value] And DateAdd("d",1,[Forms]![frmCallsQuery]![Text2].[Value])));


I would also like to obtain a total no of calls per user and display them on a report.

ie. User 1 Total Calls = 25
User 2 Total Calls = 12 etc

I am unsure as to how to go about this, ao any help would save me some more hair!!

Thanks in advance!!
 
Assuming Calls table has one entry for each call.

SELECT Calls.User_ID, Count(Calls.User_ID) AS CountOfCalls
FROM Calls
GROUP BY Calls.User_ID;

Will give you a list of User_ID and CountOfCalls.

There are two ways to write error-free programs; only the third one works.
 
thanks for your reply...

It however, comes up with the error:

"You tried to execute a query that does not include the specified expression 'User_ID' as part of an aggregate function.'

What does this mean?

Thanks
 
This would happen if the Group By field is missing or miss-spelled.

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top