Creating running totals
You usually don't have to use ORDER BY
when using aggregations, but if you want to create running totals, you should arrange your rows! In this exercise, you will create a running total of OrderPrice
.
This exercise is part of the course
Intermediate SQL Server
Exercise instructions
Create the window, partition by TerritoryName
and order by OrderDate
to calculate a running total of OrderPrice
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT TerritoryName, OrderDate,
-- Create a running total
___
-- Create the partitions and arrange the rows
___(___ TerritoryName ___ OrderDate) AS TerritoryTotal
FROM Orders