Press "Enter" to skip to content

Window Functions for Developers

Jamal Hansen provides an overview of window functions:

So let’s dive in. What problem do window functions solve? They seem to do aggregation-type activities, can’t GROUP BY do this?

The short answer is, not very well.

Window functions allow you to do things like calculate running totals, rankings, and moving averages, which tend to be very difficult to do otherwise because it requires a ‘window’ into a subset of the data.

Click through for the explanation, a primer on some of the types of window functions that are available, and several examples. I noticed that the code is impossible to read in light mode on the website, so either highlight it or go into dark mode, I guess.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.