出现默认列值问题...
以下作品:
alter table chartdata.reddit_comments add modified_datetime timestamp default now() on update now();
(添加modified_date
列,默认为当前时间戳。)
但是,以下内容会返回语法错误:
alter table chartdata.reddit_comments add modified_by varchar(50) default current_user() on update current_user();
[2018-04-06 16:56:21] [42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'current_user() on update current_user()' at line 1
我做错了什么/失踪了?
答案 0 :(得分:0)
嗨,我没有足够的代表对您的重复问题发表评论,但请查看tsibble软件包
library(data.table)
foo <- data.table(accountid = c(rep(1, 366), rep(2, 366), rep(3, 366)),
orderday = as.POSIXct(rep(seq(as.Date("2018/1/1"), as.Date("2019/1/1"), "days"), 3)),
ordervolume = rep(rnorm(366), 3))
library(tidyverse)
library(tsibble)
df <- foo %>% as_tsibble(key = id(accountid),index =orderday)
df
#Pick a size
n = 3
# Using tsibble
df %>%
group_by(accountid) %>%
mutate(rolling = slide_dbl(ordervolume, ~ mean(., na.rm = TRUE), .size = 3))