Issue with Window Function in MSSQL 2008 R2
问题 I am receving execution error in following sql script. Select TOP 1 Percent a.accode,a.voucherdate,a.credit,a.Debit, SUM(a.Debit) Over (Order By [a.accode],[a.voucherdate] ) as rdr from VoucherMain as a Order By a.accode,a.voucherdate Error Message Incorrect syntax near 'order'. Can anyone tell me what's wrong with the script syntext? 回答1: The problem is that you need SQL Server 2012 and above. Okay, I added the "and above" for future visitors, but compare 2008 OVER CLAUSE with 2012 OVER