How to concatenate arrays grouped by another column in presto?

Member

by rollin , in category: MySQL , 5 months ago

How to concatenate arrays grouped by another column in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cortez.connelly , 5 months ago

@rollin 

One way to concatenate arrays grouped by another column in Presto is to use the array_agg function along with the GROUP BY clause. Here is an example query to concatenate arrays grouped by another column:

1
2
3
4
5
6
7
SELECT 
  group_column,
  array_agg(array_column) as concatenated_array
FROM 
  your_table
GROUP BY 
  group_column;


In this query:

  • your_table is the name of your table.
  • group_column is the column you want to group by.
  • array_column is the column containing the arrays that you want to concatenate.


This query will group the rows by the group_column and concatenate the arrays from the array_column into a single array for each group.

Related Threads:

How to add arrays to another array with php?
How to concatenate arrays from multiple documents in mongodb?
How to group time column into 5 second intervals and count rows using presto?
How to concatenate multiple results into one column in oracle?
How to fill empty column from another table in oracle?
How to sort column value in mysql when results are grouped?