我想使用LISTAGG在Amazon Athena中查询。 有没有办法将数据聚合成列表或字符串?
grouping_expressions元素可以是任何函数(例如SUM,AVG,COUNT等)
答案 0 :(得分:4)
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