Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
select EventDate ,ProductCd,CustomerNo ,sum(Quantity) OVER (ORDER BY EventDate ) AS RunningTotal from #TableRerror:Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'order'.
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2012-10-23 : 05:35:02
you can't use SUM() with ORDER BY .... should be PARTITION BYKH[spoiler]Time is always against us[/spoiler]
bandi
Master Smack Fu Yak Hacker
2242 Posts
Posted - 2012-10-23 : 06:18:46
1) select EventDate ,ProductCd,CustomerNo ,sum(Quantity) OVER () AS RunningTotal from #TableRORDER BY EventDate 2) select EventDate ,ProductCd,CustomerNo ,sum(Quantity) OVER ([red]partition by ColumnNames) AS RunningTotal from #TableRORDER BY EventDate --Chandu