Amazon web services 如何在AWS Athena中使用Listag?

Amazon web services 如何在AWS Athena中使用Listag?,amazon-web-services,amazon-athena,Amazon Web Services,Amazon Athena,我想在Amazon Athena中使用Listag进行查询。 有没有办法将数据聚合到列表或字符串中 作为 分组表达式元素可以是任何函数(如SUM、AVG、COUNT等) 选项1:阵列 选项2:字符串 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] with t(i

我想在Amazon Athena中使用Listag进行查询。 有没有办法将数据聚合到列表或字符串中

作为

分组表达式元素可以是任何函数(如SUM、AVG、COUNT等)

选项1:阵列
选项2:字符串
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]
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