在 Athena Aws 中连接行值 [英] Concatenating row values in Athena Aws

查看:23
本文介绍了在 Athena Aws 中连接行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个列,可以说是 id 和 values.我想连接按 id col 分组的值.例如.我有ID 值1个1个2个2 乙我需要输出为ID 值1 a, b2 a, b

I've 2 cols lets say id and values. I want to concatenate values grouped by id col. for eg. I've ID Values 1 a 1 b 2 a 2 b I need the output as ID Values 1 a,b 2 a,b

推荐答案

您可以使用 array_agg 后跟 array_join

select id, array_join(array_agg(values),',') from table group by 1

array_agg 会给你一个包含相同 id 的所有值的数组,array_join 会将它们连接成一个字符串.请参阅文档.

The array_agg will give you an array of all values with the same id, and the array_join will concatenate them into a string. See the docs.

这篇关于在 Athena Aws 中连接行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆