Reputation: 587
When I run the query below (from a temp table I created called #Temp_CallHistory), I get the error: "The function 'ROW_NUMBER' may not have a window frame."
SELECT RootCall_Id
, CallID
, CallCode
, CreationDT
, ROW_NUMBER() OVER(PARTITION BY RootCall_Id
ORDER BY CreationDT
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS RankOfEvents
FROM #Temp_CallHistory;
However, if I run the same query without specifying "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW", I do not get the error.
Does anyone have an idea why I'm getting this error when I specify "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"? Note that I also get the error when I explicitly specify the default "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW".
Upvotes: 0
Views: 4386
Reputation: 21757
That is because ROW_NUMBER
is a ranking function and does not accept the RANGE
/ROWS
argument. You can read more about this here in the General Remarks section.
Upvotes: 3