当我在ACCESS 2007中运行以下SQL时
选择位置,COUNT(公寓楼)AS TotalBuildings管理公寓COUNT(公寓楼)> 3按地点排序按COUNT(ApartmentBuildings)DESC;
我收到以下错误:
在where子句中不能有聚合函数.如何构建此查询以获取所有具有大于3的ApartmentBuildings数量的位置?
使用having而不是where:
Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged
From Apartments
Group By Location
Having COUNT(ApartmentBuildings) > 3
Order By COUNT(ApartmentBuildings) DESC;
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅此页面