【发布时间】:2015-11-21 22:32:51
【问题描述】:
我正在尝试通过查询更新 Redshift 中的表:
update mr_usage_au au
inner join(select mr.UserId,
date(mr.ActionDate) as ActionDate,
count(case when mr.EventId in (32) then mr.UserId end) as Moods,
count(case when mr.EventId in (33) then mr.UserId end) as Activities,
sum(case when mr.EventId in (10) then mr.Duration end) as Duration
from mr_session_log mr
where mr.EventTime >= current_date - interval '1 days' and mr.EventTime < current_date
Group By mr.UserId,
date(mr.ActionDate)) slog on slog.UserId=au.UserId
and slog.ActionDate=au.Date
set au.Moods = slog.Moods,
au.Activities=slog.Activities,
au.Durarion=slog.Duration
但我收到以下错误:
ERROR: syntax error at or near "au".
【问题讨论】:
-
Redshift 不允许在更新语句的更新部分使用别名。您必须明确使用整个表名。但是,您可以在更新的 FROM 子句中指定别名。来源:docs.aws.amazon.com/redshift/latest/dg/r_UPDATE.html
标签: postgresql amazon-web-services sql-update amazon-redshift