I want to use LISTAGG for querying in Amazon Athena. Are there any ways to aggregate data into list or string?
As Amazon Athena User Guide,
The grouping_expressions element can be any function (such as SUM, AVG, COUNT, etc.)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With