想象一下我有一张像这样的桌子:
games (
scores INTEGER[]
)
它有价值观
{1,2}
{3,4}
{}
我想对该数组进行任意聚合。
例如,我该怎么做SELECT SUM(scores) AS total FROM games
?还是平均数?还是最大值?
我想出去:
3
7
0
我试过SELECT SUM(UNNEST(scores)) AS total FROM games
了,但那给了ERROR: aggregate function calls cannot contain set-returning function calls
.
您需要一个标量子查询: