select * from temp10
k v
ㅡㅡㅡㅡㅡㅡ
a {a,b}
a {c}
b {d,e}
b {f}
to
k v
ㅡㅡㅡㅡㅡㅡ
a {a,b,c}
b {d,e,f}
I want these results.
my try ↓
select k,json_agg(v)
from temp10
group by k
=
k v
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
a [["a","b"], ["c"]]
b [["d","e"], ["f"]]
select k,array_agg(v)
from temp10
group by k
=
SQL Error [2202E]: ERROR: cannot accumulate arrays of different dimensionality
help me
Is there anything lacking in my explanation? Is there anything lacking in my explanation? Is there anything lacking in my explanation?
1条答案
按热度按时间gkn4icbw1#
You can flatten v and aggregate as a new array -