我正在尝试编写一个脚本,该脚本需要每小时平均一次的系列数据。即我每隔5分钟就有5年的数据,但我需要5年的小时平均值。 Postgresql似乎在抱怨已经在那里的group by子句中缺少列?我在这里犯了什么男生错误?
SELECT
time_audit_primary.clockyear,
time_audit_primary.clockmonth,
time_audit_primary.clockday,
time_audit_primary.clockhour,
AVG (time_audit_primary.time_offset) AS timeoffset,
AVG (time_audit_primary.std_dev) AS std_dev
FROM tempin.time_audit_primary
GROUP BY (time_audit_primary.clockyear,
time_audit_primary.clockmonth,
time_audit_primary.clockday,
time_audit_primary.clockhour)
答案 0 :(得分:2)
它是导致错误的group by
列周围的括号。只需删除它们:
SELECT
time_audit_primary.clockyear,
time_audit_primary.clockmonth,
time_audit_primary.clockday,
time_audit_primary.clockhour,
AVG (time_audit_primary.time_offset) AS timeoffset,
AVG (time_audit_primary.std_dev) AS std_dev
FROM tempin.time_audit_primary
GROUP BY time_audit_primary.clockyear,
time_audit_primary.clockmonth,
time_audit_primary.clockday,
time_audit_primary.clockhour