当运行以下查询时,我会收到一个错误:
SELECT
$__timeGroupAlias(receivedat,$__interval),
SUBSTRING(message, '(?:[0-9]{1,3}\.){3}[0-9]{1,3}') AS the_address,
COUNT (message) AS ip
FROM systemevents
WHERE
$__timeFilter(receivedat)
GROUP BY the_address
ORDER BY ip DESC
LIMIT 10
db查询错误: pq:列"systemevents.receivedat“必须出现在GROUP子句中或在聚合函数中使用
如何避免此错误?
我正在使用Grafana和PostgreSQL 10。
发布于 2021-09-01 10:40:41
当使用"group“时,您选择的每一列都必须在聚合函数中使用或包含在"group”子句中。
请考虑以下查询:
select a, b, c
from ...
group by a, b
有可能,a和b的每个组合都有多个c值。您的查询应该返回哪一个?
数据库也不知道,所以抛出了这个错误。
https://dba.stackexchange.com/questions/298803
复制相似问题