2016-01-24 60 views
0

語法似乎有錯誤。我得到這個錯誤語法錯誤不知道是否redshift或sql

 
ERROR: syntax error at or near "update" 
    Position: 188 

update t 
^ 

Execution time: 0.11s 

有人可以請幫忙。我不知道,如果它是一個SQL或只是一個紅移錯誤(我是新來的SQL和紅移兩者)

With tbl as 
(
Select Count(1) as cnt, b.ucn 
FROM 
storiacloud.schl_storia_school_status_try b 
INNER JOIN 
storiacloud.vw_storia_oms_orders a ON a.school_ucn = b.ucn 
Group By b.ucn 
) 
update t 
SET no_of_orders = tbl.Cnt 
From tbl 
join storiacloud.schl_storia_school_status_try as t on t.ucn = tbl.ucn 
+2

將是有益的。使其成爲最小的非工作示例(例如:排除未出現在查詢中的表的列)。還請指定您是否在vanilla PostgreSQL上嘗試了查詢,以及您嘗試了哪個版本。 –

+0

修正了一些錯別字和語法 – Stefan

回答

2

紅移不...更新支持。

Redshift是PostgreSQL的衍生產品,但是它在PostgreSQL 8.0.2版本中被派生出來。 WITH ... UPDATE語句直到9.1才被添加到PostgreSQL中。

見:如果你提供一個完整的測試情況,包括你的表的DDL

Redshift UPDATE

PostgreSQL 8.0 UPDATE

PostgreSQL 9.1 UPDATE