我想获取与id
此示例数据中的每个相关联的所有单词的数组:
id | words
---|------------------
1 | {foo,bar,zap,bing}
2 | {foo}
1 | {bar,zap}
2 | {bing}
1 | {bing}
2 | {foo,bar}
输出:
id | allwords
---|--------------------------------
1 | {foo,bar,zap,bing,bar,zap,bing}
2 | {foo,bing,foo,bar}
我尝试使用array_agg(words)
但它产生:
ERROR: could not find array type for data type text[]
这里的正确方法是什么?我想要所有的单词,甚至是重复的单词。