I have a column numbers, positive or negative, such as the Val column in the table below;
msg = table(1..100 as id, rand(-100..100,100) as Val)
Now I want to calculate the moving summation for Val with the rolling window of length 10 ,but only calculate positive numbers in Val.Something like select msum( if(val>0), 10) from msg.
使用函数iif
将所有负数转换为零,然后使用msum
计算滚动和。
msum(iif(val > 0, val, 0), 10)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.