如何在PostgreSQL中向列添加注释?
create table session_log (
UserId int index not null,
PhoneNumber int index);
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Amazon Redshift中创建索引但是我收到了一个错误
create index on session_log(UserId);
Run Code Online (Sandbox Code Playgroud)
UserId 是一个整数字段.
我正在尝试从查询中更新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
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
Run Code Online (Sandbox Code Playgroud)ERROR: syntax error at or near "au".
我在 Redshift 中有一个表,其中包含我想要删除的重复行,
为此,我创建了归档 ID,我想更新他以删除重复的行,我正在尝试运行此查询,但它不起作用
update mr_usage
set id=row_number () over (partition by uid,date(ts),title order by ts)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
错误:无法在更新中使用窗口函数
我正在寻找一种更新该字段的方法
我有以下data.frame
user_id 1 2 3 4 5 6 7 8 9
1 54449024717783 0 0 1 0 0 0 0 0 0
2 117592134783793 0 0 0 0 0 1 0 0 0
3 187145545782493 0 0 1 0 0 0 0 0 0
4 245003020993334 0 0 0 0 0 1 0 0 0
5 332625230637592 0 1 0 0 0 0 0 0 0
6 336336752713947 0 1 0 0 0 0 0 0 0
Run Code Online (Sandbox Code Playgroud)
我想要做的是创建一个列(并删除1:9)并插入列名称,其中我有值1,每个用户只包含值为1的列,
如果我正在运行以下功能:
rowSums(users_cluster(users_cluster), …Run Code Online (Sandbox Code Playgroud)