我希望在Amazon Athena中使用LISTAGG进行查询。有没有将数据聚合成列表或字符串的方法?
根据Amazon Athena用户指南,grouping_expressions元素可以是任何函数(如SUM、AVG、COUNT等)。
根据Amazon Athena用户指南,grouping_expressions元素可以是任何函数(如SUM、AVG、COUNT等)。
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
LISTAGG( [DISTINCT] aggregate_expression [, 'delimiter' ] )
[ WITHIN GROUP (ORDER BY order_list) ]
SELECT LISTAGG(sellerid, ', ')
WITHIN GROUP (ORDER BY sellerid)
FROM sales WHERE eventid = 4337;