harshil bhatt
harshil bhatt

Reputation: 152

syntax error dont know if redshift or sql

There seems to be error with the syntax. I am getting this error

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

update t
^

Execution time: 0.11s

Can someone please help. I dont know if it is a sql or just a redshift error (I am new to sql and redshift both)

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

Upvotes: 0

Views: 715

Answers (1)

Aaron Perrin
Aaron Perrin

Reputation: 141

Redshift doesn't support WITH ... UPDATE.

Redshift is a derivative of PostgreSQL, but it was forked at PostgreSQL version 8.0.2. The WITH ... UPDATE statement wasn't added to PostgreSQL until 9.1.

See:

Redshift UPDATE

PostgreSQL 8.0 UPDATE

PostgreSQL 9.1 UPDATE

Upvotes: 2

Related Questions