2016-09-22 47 views
0

The Table "Cric_Team" looks like thisSQL Server 2012中無界的以下工作方式如何工作?

當我在SQL Server 2012中執行以下查詢時,'無界跟隨'不計算直到該分區的最後一行的總和。但是,根據定義,它應該計算到當前行的最後一行。

SELECT Cric_Id,Cric_First_Name,Cric_Last_Name,Cric_Role,運行,幾個世紀以來,第五十AS五十年代,鴨,SUM(鴨子)OVER(PARTITION BY Cric_Role ORDER BY鴨子電流範圍內行和無限的以下兩項)AS Total_Ducks FROM Cric_Team

The Screenshot of table after executing the query

回答

0

如何使用降序排序呢?這是做你想做的嗎?

SELECT Cric_Id, Cric_First_Name, Cric_Last_Name, Cric_Role, Runs, 
     Centuries, Fifty AS Fifties, Ducks, 
     SUM(Ducks) OVER (PARTITION BY Cric_Role ORDER BY Ducks DESC) AS Total_Ducks 
FROM Cric_Team; 
+0

不加'DESC'也是按降序排列。不知道發生了什麼。 –

相關問題