Advanced SQL
CTEs, window functions, ranking, and row-level analytics.
🧠
Advanced7 topics
Common Table Expressions (CTEs)
Name each step of a query with WITH, reuse it, and generate series with WITH RECURSIVE
Advanced 25m
Introduction to Window Functions
Add aggregated or ranked values to every row — without collapsing anything
Advanced 18m
ROW_NUMBER()
Assign unique sequential numbers — and solve top-N-per-group
Advanced 12m
RANK()
Rank rows with tied values getting the same position — gaps after ties
Advanced 10m
DENSE_RANK()
Rank without gaps — consecutive numbers even when values tie
Advanced 10m
LAG()
Access the previous row's value — essential for trend analysis
Advanced 12m
LEAD()
Look ahead to the next row's value — the mirror of LAG
Advanced 10m