1. Learn
  2. /
  3. Courses
  4. /
  5. Data Manipulation in SQL

Exercise

PARTITION BY multiple columns

The PARTITION BY clause can be used to break out window averages by multiple data points (columns). You can even calculate the information you want to use to partition your data! For example, you can calculate average goals scored by season and by country, or by the calendar year (taken from the date column).

In this exercise, you will calculate the average number home and away goals scored Legia Warszawa, and their opponents, partitioned by the month in each season.

Instructions

100 XP
  • Construct two window functions partitioning the average of home and away goals by season and month.
  • Filter the dataset by Legia Warszawa's team ID (8673) so that the window calculation only includes matches involving them.