加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

聚合函数的SQL比较

发布时间:2020-12-14 04:54:01 所属栏目:百科 来源:网络整理
导读:当我在ACCESS 2007中运行以下SQL时 Select Location, COUNT(ApartmentBuildings) AS TotalIBuildingsManaged From Apartments Where COUNT(ApartmentBuildings) 3 Group By Location Order By COUNT(ApartmentBuildings) DESC; 我收到以下错误: 在where子句
当我在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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读