Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Quick Refresher
4. Introduction
PARTITION BY ORDER BY with Window Frames
Using PARTITION BY ORDER BY with Analytical Functions
Summary and Review


Before we get down to work, let's explain what you'll learn today.

In Part 3, you learned what PARTITION BY is. It allows you to compute certain functions independently for groups of rows and still maintain their individual character.

In Part 3, we only used PARTITION BY with familiar aggregate functions: AVG(), COUNT(), MAX(), MIN(), SUM(). None of these functions required the use of ORDER BY: the order of rows simply doesn't matter in this case.

However, in Part 4, 5 and 6, you got to know new elements where the order does matter: ranking functions, window frames and analytical functions.

In this part, we'll teach you how to use PARTITION BY with these new elements. You will need an ORDER BY clause – hence the name of this part. Remember to use the proper order: PARTITION BY comes before ORDER BY. Otherwise, your query won't make sense.


Click Next exercise to continue.