建立累計總和
使用彙總時通常不需要 ORDER BY,但如果你要建立累計總和,就「應該」先排序列!在這個練習中,你會對 OrderPrice 建立累計總和。
本練習屬於課程
SQL Server 中級
練習說明
建立視窗,依 TerritoryName 分區,並依 OrderDate 排序,以計算 OrderPrice 的累計總和。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
SELECT TerritoryName, OrderDate,
-- Create a running total
___
-- Create the partitions and arrange the rows
___(___ TerritoryName ___ OrderDate) AS TerritoryTotal
FROM Orders