错误:在sql server 2012中使用分区时,语法接近顺序错误

时间:2017-03-30 10:57:12

标签: sql-server sql-server-2012

我的查询是计算每6个星期的累计总数。

;WITH CTE_Group AS (
   SELECT id, ClientId, extraId, weekCount,  Total1,Total2,       
         (ROW_NUMBER() OVER (PARTITION BY extraId ORDER BY ClientId,weekCount) + 5) / 6 AS grp
   FROM Sale
)
SELECT id, id, ClientId, extraId, weekCount,  Total1,Total2, 
      SUM(Total1+Total2) OVER (PARTITION BY extraId, grp ORDER BY ClientId,weekCount)
FROM CTE_Group

但它显示"语法接近顺序"。

提前致谢!!

0 个答案:

没有答案