Module 04 of 12

Advanced SQL

Lessons

About This Module

Basic queries answer simple questions. Real business questions, such as "which customers spend more than the average?" or "how does each month compare with the one before it?", need more. Advanced SQL gives you the tools to break a hard problem into clear, readable steps.

You'll start with subqueries and common table expressions (CTEs), two ways of building a query on top of another query. Then you'll learn window functions for rankings, running totals, and row-by-row comparisons, CASE statements for adding conditional logic to your results, and stored procedures for saving queries you run again and again.

Together these are the techniques analysts use to prepare data for reports. In the next module, Statistics for Analysts, you'll learn how to interpret what that data is telling you.

Lessons

4 videos
01

Subqueries

How to put one query inside another to calculate averages, filter on results from another table, and answer questions a single query can't.

02

CTEs (Common Table Expressions)

How the WITH clause lets you name an intermediate result and build on it, so long queries stay readable and easy to debug.

03

Window Functions

How OVER, PARTITION BY and ORDER BY let you rank rows, calculate running totals, and compare a row with the ones around it without collapsing your data.

04

CASE Statements

How to add if/then logic to a query, for example grouping values into categories or labelling rows by condition.