【发布时间】:2014-03-26 10:13:35
【问题描述】:
我正在尝试将列值作为数组获取,以便在 function array_agg_transfn() to calculate the median value as defined in the Postgres Wiki. 中使用它们
我根据当前行获取的特定列的列值。例如,当前行下方 13 行。我尝试使用以下查询:
select a."Week_value",
array_agg(a."Week_value")
over(order by prod_name,week_date desc
rows between 0 preceding and 12 following)
from vin_temp_table
但收到此错误消息:
array_agg_transfn called in non-aggregate context
是否可以从接下来的 n 行中的列值构建一个数组?
【问题讨论】:
-
最好为您的案例提供表定义和一些示例值,最好是在 SQLfiddle (example) 或类似的东西中。并在处理您的声明时对其进行修正,对
a的引用无效。
标签: sql postgresql aggregate-functions postgresql-8.4 window-functions