1
我正在使用aws红移,并且遇到了一个情况,那就是我有多个唯一ID的行,并且需要使用SQL将行组合到每个唯一ID的一列中。我搜索了如何做到这一点,它看起来像在postgres中是可能的,但是,建议的方法使用的功能如:string_agg和array_agg,这些功能在aws redshift中不可用。这甚至有可能使用红移?有没有人知道不使用函数来攻击这个问题的方法?在Redshift中将多行转换为列
以下是我正在处理的内容。下表代表给我,我需要组建成每个ID一列的行查询:
+----+----------+---------+-------+
| ID | make | model | type |
+----+----------+---------+-------+
| 1 | ford | mustang | coupe |
| 1 | toyota | celica | coupe |
| 2 | delorean | btf | coupe |
| 2 | mini | cooper | coupe |
| 3 | ford | mustang | coupe |
| 3 | | | |
+----+----------+---------+-------+
什么我希望直到结束:
+----+----------+---------+-------+----------+---------+-------+
| ID | make | model | type | make | model | type |
+----+----------+---------+-------+----------+---------+-------+
| 1 | ford | mustang | coupe | toyota | celica | coupe |
| 2 | delorean | bttf | coupe | mini | cooper | coupe |
| 3 | ford | mustang | coupe | | | |
+----+----------+---------+-------+----------+--------+--------+
谢谢!这真的有帮助 – user1026498