【发布时间】:2019-02-01 18:39:26
【问题描述】:
我在 aws athena 中有一个包含以下列的表格
Company name Employee Name Salary
------------------------------------
Apple | John | 50
Apple | Dima | 100
Microsoft | Bart | 75
Google | Harry | 90
Google | Noah | 80
我想通过单个查询生成下表,最好使用数组映射
Company name Employee Data
------------------------------------
Apple | [John,50],[Dima,100]
Microsoft | [Bart,75]
Google | [Harry,90],[Noah,80]
你知道怎么做吗?
【问题讨论】:
-
是否有
listagg函数或类似的东西? -
我已经用arrayagg解决了,但我担心值的顺序可能不一样,例如:select company_name, array_join(array_agg(salary),','), array_join (array_agg(employee_name),',') from db.stats group by company_name;
标签: sql amazon-athena presto aws-glue