Window Functions

OVER, PARTITION BY, frame semantics, and the analytical patterns — rankings, running totals, gaps & islands — that replace application-side loops.

Window functions are the most underused tool in SQL. Unlike aggregates, they return one row per input row — so you can rank, compare to neighbours, and compute running totals without losing the detail rows you started with. These lessons cover the fundamentals through advanced analytical patterns.

Paired course

Master Window Functions

Go deeper with structured exercises, datasets, and production patterns.

See the Course

Go deeper

The Art of PostgreSQL

These lessons are the foundation. The book gives you the complete treatment, with real datasets you can run and the production patterns that turn thousands of lines of code into simple queries.

Get the Book — $89