當我在Access 2007SQL比較
Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged From Apartments Where COUNT(ApartmentBuildings) > 3 Group By Location Order By COUNT(ApartmentBuildings) DESC;
我碰到下面的錯誤運行下面的SQL:
不能有where子句中聚合函數。我應該如何形成這個查詢來獲得所有的ApartmentBuildings數量大於3的位置?
如果你使用Access查詢生成器,它會爲您編寫適當的SQL,它將使用HAVING子句而不是WHERE子句。 – 2011-06-03 03:07:51