Get startedGet started for free

Window functions with aggregations (II)

In the last exercise, you calculated the sum of all orders for each territory. In this exercise, you will calculate the number of orders in each territory.

This exercise is part of the course

Intermediate SQL Server

View Course

Exercise instructions

  • Count the number of rows in each partition.
  • Partition the table by TerritoryName.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT OrderID, TerritoryName, 
       -- Number of rows per partition
       ___ 
       -- Create the window and partitions
       ___ AS TotalOrders
FROM Orders
Edit and Run Code