2013-04-01 39 views
1

我試圖在表上使用unpivot。我使用Workbench/J作爲客戶端來進行亞馬遜紅移。下面的SELECT語句不工作:UNPIVOT與SQL Workbench/J和亞馬遜aws紅移

SELECT 
    campaign_id, 
    C.B, 
    C.A 
FROM campaign 
UNPIVOT 
(
    A FOR B IN (item1, item2, item3) 
) AS C 

我得到以下錯誤:

ERROR: syntax error at or near "for" Position: 62 [SQL State=42601]

如果可能的話,我想使用UNPIVOT而不是UNION,它不承認UNNEST作爲功能。

+1

你肯定有一個'unpivot'功能?並非所有的東西都支持不透明。 – Taryn

回答

0

UNPIVOT語法正確但不是每個數據庫都支持該功能。

你可能要考慮使用UNION ALL

select campaign_id, 'item1' as B, item1 as A 
from campaign 
union all 
select campaign_id, 'item2' as B, item2 as A 
from campaign 
union all 
select campaign_id, 'item3' as B, item3 as A 
from campaign