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

COUNT() Function Usage

Status
Not open for further replies.

Vem786

Technical User
Dec 2, 2003
52
0
0
US
Hi:
I'm using count() function in a SQL Query in MS Access as --

SELECT COUNT(Dept), Prof_Name FROM Departments WHERE Dept IN ("English","Math","Engg");

When I save this & hit RUN, Access specifies Error saying "You Tried to execute a query that does not include the specified expression "Prof_Name" as part of an aggregate function".

Can anyone get me this query running??

I'm supposed to do this Count by "Dept" the Number of Prof_Name.

Thanks!!
 
in sql, if you have aggregate functions you have to group by all the fields that are not included in the aggregate functions. So,

Code:
SELECT COUNT(Dept), Prof_Name FROM Departments WHERE Dept IN ("English","Math","Engg") GROUP BY Prof_Name;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top