Session Ready
Exercise

PARTITION BY a column

The PARTITION BY clause allows you to calculate separate "windows" based on columns you want to divide your results. For example, you can create a single column that calculates an overall average of goals scored for each season.

In this exercise, you will be creating a data set of games played by Legia Warszawa (Warsaw League), the top ranked team in Poland, and comparing their individual game performance to the overall average for that season.

Where do you see more outliers? Are they Legia Warszawa's home or away games?

Instructions
100 XP
  • Complete the two window functions that calculate the home and away goal averages. Partition the window functions by season to calculate separate averages for each season.
  • Filter the query to only include matches played by Legia Warszawa, id = 8673.