gpt4 book ai didi

sql-server - SQL Server 错误 : 'BETWEEN ... FOLLOWING AND CURRENT ROW' is not a valid window frame and cannot be used with the OVER clause. '?

转载 作者:行者123 更新时间:2023-12-04 06:51:23 24 4
gpt4 key购买 nike

我试图将 3 个月的净值与 1 个月的净值相加。编码

SELECT [CMONTH]
,[ID]
,[NET_VALUE_1M]
,SUM(CAST([NET_VALUE_1M] as float)) OVER
(PARTITION BY [ID] ORDER BY [CMONTH]
ROWS BETWEEN 3 FOLLOWING AND CURRENT ROW) as 'NET_VALUE_3M'
FROM [Channel_AGG]

正在触发错误
Msg 4193, Level 16, State 4, Line 2
'BETWEEN ... FOLLOWING AND CURRENT ROW' is not a valid window frame
and cannot be used with the OVER clause.

为什么,是什么导致了这种情况以及如何解决?

最佳答案

你需要使用

ROWS BETWEEN CURRENT ROW AND 3 FOLLOWING

The upper bound cannot be smaller than the lower bound.

关于sql-server - SQL Server 错误 : 'BETWEEN ... FOLLOWING AND CURRENT ROW' is not a valid window frame and cannot be used with the OVER clause. '?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43540984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com