presto group_concat
时间: 2023-08-30 18:08:52 浏览: 146
Presto doesn't have a built-in GROUP_CONCAT function like some other database systems do. However, you can achieve the same result using the `array_agg` and `array_join` functions in Presto.
Here's an example query that demonstrates how to concatenate values from a column for each group:
```sql
SELECT group_id, array_join(array_agg(value), ',') AS concatenated_values
FROM your_table
GROUP BY group_id;
```
This query groups the rows by the `group_id` column and aggregates the `value` column into an array using `array_agg`. Then, it uses `array_join` to concatenate the array elements with a comma separator.
Please replace `your_table`, `group_id`, and `value` with the actual table and column names in your case.
阅读全文