I have the following table:
my_id, my_array
1 , [5, 6, 3]
2 , [1, 5]
3. , [6, 7, 5]
Would it be possible to do a cast such that the output table would be something like:
my_id, my_str
1 , "5,6,3"
2 , "1,5"
3. , "6,7,5"
Or if there is any way I could directly group by my_array would be fine too. Thanks!
Use array_join function
select array_join(my_array,',') my_str
And of course you can group by array. This works:
select max(id) id , my_array
from
(select 1 id, array[5, 6, 3] as my_array) s
group by my_array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With