【发布时间】:2021-04-26 11:28:40
【问题描述】:
我有一个名为 metadata 的 Redshift 表,其中包含以下列:
| id | key | value |
|---|---|---|
| 1001 | code1 | my value |
| 1001 | code2 | another |
| 1001 | code3 | yet another |
| 1002 | code1 | new one |
| 1002 | code2 | here |
| 1002 | code3 | last |
| 1003 | code1 | hello |
| 1003 | code2 | goodbye |
| 1004 | code2 | now |
| 1004 | code3 | then |
我想要一个返回如下的查询:
| id | code1 | code2 | code3 |
|---|---|---|---|
| 1001 | my value | another | yet another |
| 1002 | new one | here | last |
| 1003 | hello | goodbye | |
| 1004 | now | then |
请注意,并非所有 ID 都包含全部 3 个代码。有些会有 1 或 2 个,有些会全部 3 个,还有一些仍然没有。
【问题讨论】:
标签: sql amazon-web-services amazon-redshift