我想使用LISTAGG在Amazon Athena中进行查询。
有什么方法可以将数据聚合到列表或字符串中?
作为Amazon Athena User Guide,
The grouping_expressions element can be any function (such as SUM, AVG, COUNT, etc.)
最佳答案
选项1:数组
with t(i) as (select 1 union all select 2 union all select 3)
select array_agg(i) as result
from t
;
result
-----------
[3, 2, 1]
选项2:字符串
with t(i) as (select 1 union all select 2 union all select 3)
select array_join(array_agg(i),',') as result
from t
;
result
--------
1,3,2
关于amazon-web-services - 如何在AWS Athena中使用LISTAGG?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41821474/