当前位置 : 主页 > 手机开发 > 其它 >

聚合函数的SQL比较

来源:互联网 收集:自由互联 发布时间:2021-06-22
当我在ACCESS 2007中运行以下SQL时 Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged From Apartments Where COUNT(ApartmentBuildings) 3 Group By Location Order By COUNT(ApartmentBuildings) DESC; 我收到以下错误:
当我在ACCESS 2007中运行以下SQL时

Select Location,
COUNT(ApartmentBuildings) AS
TotalIBuildingsManaged From Apartments
Where COUNT(ApartmentBuildings) > 3
Group By Location Order By
COUNT(ApartmentBuildings) DESC;

我收到以下错误:

在where子句中不能有聚合函数.如何构建此查询以获取所有具有大于3的ApartmentBuildings数量的位置?

使用而不是在哪里:

Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged 
From Apartments 
Group By Location
Having COUNT(ApartmentBuildings) > 3  
Order By COUNT(ApartmentBuildings) DESC;

了解更多信息see this page

网友评论