Calculating standard deviation
Calculating the standard deviation is quite common when dealing with numeric columns. In this exercise, you will calculate the running standard deviation, similar to the running total you calculated in the previous lesson.
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 standard deviation of OrderPrice
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT OrderDate, TerritoryName,
-- Calculate the standard deviation
___
OVER(PARTITION BY TerritoryName ORDER BY OrderDate) AS StdDevPrice
FROM Orders