我有一个表,其中包含列item,store,date和fcst。对于每个商品存储日,我需要对下一个x天的预测天数求和,但是每个商品存储组合的x发生变化。以下代码不起作用,建议我将X FOLLOWING替换为静态整数FOLLOWING:
不运行:
SELECT
ITEMNBR,
STORENBR,
DT,
SUM(FCST)OVER(PARTITION BY STORENBR,ITEMNBR ORDER BY DT BETWEEN CURRENT ROW AND X ROWS FOLLOWING) AS VALUE
FROM TABLENAME
运行:
SELECT
ITEMNBR,
STORENBR,
DT,
SUM(FCST)OVER(PARTITION BY STORENBR,ITEMNBR ORDER BY DT BETWEEN CURRENT ROW AND 7 ROWS FOLLOWING) AS VALUE
FROM TABLENAME
任何修复或建议的解决方法?