SQL Server 2012: sum over order by gives error Incorrect syntax near 'order'
问题 declare @t table (cid int, amount int, cname varchar) insert into @t values (6, 20, 'C'), (7, 30, 'C'), (8, 10, 'C'), (9, 10, 'D') select sum(amount) over (partition by cname order by cid), * from @t Throws an error: Incorrect syntax near 'order'. https://msdn.microsoft.com/en-us/library/ms187810.aspx Isn't sum over order by supported in SQL Server 2012? If I remove order by and use only partition by it works but for 'C' I get 60 for all rows. I want to get running total. More info: Microsoft