Skip to main content
dbSyntax
Home CoursePracticeReferenceModelingInterview Prep
Start Here
  • What is a database?
  • What is SQL?
  • SQL syntax
  • SQL datatypes
  • How to run queries (tooling)
  • How to read tables/ERDs
SQL Foundations
  • SELECT / FROM
  • ORDER BY
  • LIMIT / OFFSET
  • DISTINCT
  • Aliases
Filtering
  • WHERE
  • AND / OR / NOT
  • IN / BETWEEN
  • LIKE
  • NULL (IS NULL, COALESCE)
Aggregation
  • COUNT / SUM / AVG / MIN / MAX
  • GROUP BY
  • HAVING
  • CASE & Conditional Aggregation
Joins
  • Joins Intro
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN
  • CROSS JOIN
  • Self Join
  • Join Debugging: Duplicates & Missing Rows
  • UNION vs UNION ALL
Subqueries & CTEs
  • Subqueries (IN / EXISTS)
  • Correlated Subqueries
  • WITH (CTEs)
Window Functions
  • OVER / PARTITION BY / ORDER BY
  • ROW_NUMBER / RANK / DENSE_RANK
  • LAG / LEAD
  • Moving Averages & Running Totals
  • QUALIFY
Data Cleaning
  • String Cleanup
  • Date Parsing
  • Deduping
Analytics Patterns
  • Top-N Per Group
  • Cohorts & Retention
  • Funnels
  • Rolling Metrics & Period-over-Period
Performance Modeling
  • Index Intuition
  • Normal Forms
  • Reading Explain Plans
Capstone
  • Capstone Part 1: KPI Baseline
  • Capstone Part 2: Cohorts & Retention
  • Capstone Part 3: Segments & Recommendation
Home / Course / Window Functions

Window Functions

Learn SQL window functions with practical examples and guided drills on dbSyntax.

Start with OVER / PARTITION BY / ORDER BY

OVER / PARTITION BY / ORDER BY

Intermediate

A window function computes a value across a set of related rows, without collapsing them the way GROUP BY does. Every input row stays in the...

ROW_NUMBER / RANK / DENSE_RANK

Intermediate

Three ranking functions, one job: number rows inside a window in order. They differ only in how they handle ties. | Function | Ties | Gaps a...

LAG / LEAD

Intermediate

LAG pulls the previous row's value into the current row. LEAD pulls the next row's value. Together they turn per-row comparisons ("change vs...

Moving Averages & Running Totals

Intermediate

A running total is a windowed SUM that accumulates from the start of a series to the current row. A moving average is a windowed AVG over th...

QUALIFY

Intermediate

Every window-function lesson so far has hit the same wall: you compute rn, then you can't filter on it....

dbSyntax Write and Run SQL in Your Browser
CoursePracticeReferenceModelingInterview PrepPrivacyTerms
© 2026 dbSyntax.