我正在考虑的唯一方法是将(今天-365)和(今天-65 + 90)之间的值相加,然后每次移动1天,但这是不切实际的。有办法解决吗?
答案 0 :(得分:0)
如果每天有一行:
select top (1) t.*
from (select t.*, sum(x) over (order by date rows between 89 preceding and current row) as sum_90
from t
) t
order by sum_90 desc;