sign up today

Ready to Go Pro with Maven Analytics

Ready to Go Pro with Maven Analytics

Sign up today an unlock full access to all data and AI learning content.

free email course

SQL with AI

Day 3

Intermediate

free email course

SQL with AI

Day 3

Intermediate

The Brief

Wow, I can't believe we're on Day 3 already! In case you forgot, it's still John at Maven Analytics here.

You've got CTEs down. Today is the big one: window functions.

If there's a single SQL concept that separates junior analysts from senior ones, this is it. Not because window functions are rare, they show up in almost every analyst dashboard, almost every performance report, almost every interview at the mid-to-senior level. But because most people learn SQL without ever encountering them, so they arrive at complex analytical questions and reach for GROUP BY when the right tool is something else entirely.

The one-sentence explanation

GROUP BY collapses rows into groups and returns one row per group. Window functions calculate across a set of rows, but keep every row. That's the difference.

Example: if you want the total revenue per category, GROUP BY gives you one row per category. If you want the total revenue per category shown alongside every individual order, a window function does that, each order row gets the category total as an additional column.

Environment Setup

Environment Setup

exercise 1

RANK() and DENSE_RANK()

5 min

exercise 1

RANK() and DENSE_RANK()

5 min

exercise 2

LAG() for month-over-month change

5 min

exercise 2

LAG() for month-over-month change

5 min

exercise 3

SUM() OVER() for running totals

5 min

exercise 3

SUM() OVER() for running totals

5 min

Go Deeper

Go Deeper

Looking forward to Tomorrow

Looking forward to Tomorrow

© Maven Analytics, LLC | All Rights Reserved

© Maven Analytics, LLC | All Rights Reserved

© Maven Analytics, LLC | All Rights Reserved