Could somebody please tell me why this is causing a syntax error in SQL Server 2008 R2? It works fine in SQL Server 2014.
SELECT
CustomerId, RequestDate,
SUM(InitialActualCount + (KeyCardCount * x.Activity))
OVER (PARTITION BY CustomerId ORDER BY RowNumber) AS TotalActualCount,
RowNumber
FROM
(SELECT
*,
ROW_NUMBER() OVER (PARTITION BY CustomerId
ORDER BY CustomerID, RequestDate) AS RowNumber
FROM
RequestTable) x
Table structure:
RequestTable (CustomerId, RequestDate, KeyCardCount, Activity, InitialActualCount)
Error:
Incorrect syntax near 'order'.
Incorrect syntax near 'x'.
Thank you in advance for any help!