【发布时间】:2019-07-16 16:16:22
【问题描述】:
我有一个如下所示的数据集: 索引、键、值
1, Description, Apple
2, Type, Orange
3, Desciption, Apple
4, Type, Pickle
5, Type, Orange
我知道如果 Value 是数字的话可以这样做:
select Index,
max(Case when key = 'Description' then Value else null end)
max(case when key = 'type' the value else null end)
from table
group by Index
但鉴于我的值列是一个字符串,这不适用于我的用例。请记住这个 Redshift,所以它没有所有的 postgres 功能。 样本期望输出:
Index, Description,type
1, Apple, Orange
2, Apple, Pickle
【问题讨论】:
标签: sql amazon-web-services amazon-redshift transpose