更新附近的CTE错误

时间:2014-06-21 23:20:02

标签: sql sybase-iq

您好我正在使用Sybase 16。

每当我运行此CTE时,它都会给我一个错误:'更新附近的语法错误' ...

With Remove_Dup_Nov13(pk_viewing_prog_instance_fact, Rank_instance) As (Select pk_viewing_prog_instance_fact, row_number()over(partition by dk_programme_instance_dim, subscriber_id, account_number, instance_start_date_time_utc, instance_end_date_time_utc, instance_duration order by dk_programme_instance_dim, subscriber_id, account_number, instance_start_date_time_utc, instance_end_date_time_utc, instance_duration) rank_instance From Viewing_Cribs_Nov13 ) Update Viewing_Cribs_Nov13 Set a.Rank_instance = b.Rank_instance from Viewing_Cribs_Nov13 as a inner join Remove_Dup_Nov13 as b on a.pk_viewing_prog_instance_fact = b.pk_viewing_prog_instance_fact;

请建议。

1 个答案:

答案 0 :(得分:0)

您要使用别名设置要更新的列,而不是您要更新的表:

Update Viewing_Cribs_Nov13
Set Rank_instance = b.Rank_instance
from Viewing_Cribs_Nov13 as a
inner join
Remove_Dup_Nov13 as b
on a.pk_viewing_prog_instance_fact = b.pk_viewing_prog_instance_fact;

OR

Update a
Set Rank_instance = b.Rank_instance
from Viewing_Cribs_Nov13 as a
inner join
Remove_Dup_Nov13 as b
on a.pk_viewing_prog_instance_fact = b.pk_viewing_prog_instance_fact;