当我在访问
中运行以下查询时SELECT SUM(RegBed) AS RegBedTOTAL, PostcodeRESULTS_PostcodeNS as postcode
FROM cooltableless10;
我收到以下错误:
this query does not include the specified expression 'postcode' as part of an aggregate function.
有人可以告诉我为什么会这样吗?
答案 0 :(得分:3)
SUM
是一个聚合函数,这意味着任何非聚合列都必须包含在GROUP BY
子句中。试试这个:
SELECT SUM(RegBed) AS RegBedTOTAL, PostcodeRESULTS_PostcodeNS as postcode
FROM cooltableless10
GROUP BY PostcodeRESULTS_PostcodeNS
答案 1 :(得分:0)
您需要添加group by子句 并通过邮政编码分组 在您的查询中添加如下内容:
group by postcode
您始终需要添加group by子句并在何时对数据进行分组 在查询中使用聚合函数