2

I have a table: my_table

customer_id
-------------
 2156
 6781
 3145
 1235
 9874

I want the output to be one concat string with comma like: 2156, 6781, 3145, 1235, 9874 So far I export the table and using python to do it. I am wondering could I do it directly in Presto query? Thanks!

Edamame
  • 23,718
  • 73
  • 186
  • 320

1 Answers1

8

I don't think Presto has a string aggregation. Instead, aggregate as an array and convert to a string:

select array_join(array_agg(customer_id), ', ') as customer_ids
from my_table
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786