jeudi 27 août 2015

Update redshift table from query

I'm trying to update table in redshift from query but i received the following error , ERROR: syntax error at or near "au".

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       




Aucun commentaire:

Enregistrer un commentaire