library(dplyr, warn.conflicts = FALSE)
db <- memdb_frame(g = rep(1:2, each = 5), y = runif(10), z = 1:10)
db %>%
window_order(y) %>%
mutate(z = cumsum(y)) %>%
show_query()
db %>%
group_by(g) %>%
window_frame(-3, 0) %>%
window_order(z) %>%
mutate(z = sum(y)) %>%
show_query()
Run the code above in your browser using DataLab