I want to get an array of all words associated with each id
in this example data:
id | words
---|------------------
1 | {foo,bar,zap,bing}
2 | {foo}
1 | {bar,zap}
2 | {bing}
1 | {bing}
2 | {foo,bar}
Outputs:
id | allwords
---|--------------------------------
1 | {foo,bar,zap,bing,bar,zap,bing}
2 | {foo,bing,foo,bar}
I tried using array_agg(words)
but it yields:
ERROR: could not find array type for data type text[]
What's the proper approach here? I want all words, even the duplicates.