When I run the following SQL in ACCESS 2007
Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged From Apartments Where COUNT(ApartmentBuildings) > 3 Group By Location Order By COUNT(ApartmentBuildings) DESC;
I get the following error:
Cannot have aggregate function in where clause. How should I be forming this query to get all of the locations which have a count of ApartmentBuildings greater than 3?
Use having
instead of where
:
Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged
From Apartments
Group By Location
Having COUNT(ApartmentBuildings) > 3
Order By COUNT(ApartmentBuildings) DESC;
for more information see this page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With