We use analytics and advertising cookies to understand how the site is used and whether our ads on Facebook and Instagram work. They are set only if you accept. See our Privacy Policy for details.
Window functions compute a value across a set of related rows without collapsing them - ranking with ROW_NUMBER/RANK/DENSE_RANK, comparing to neighbors with LAG/LEAD, and running totals with SUM OVER. They're the standard tool for "top N per group" and period-over-period questions, and analytics-heavy companies treat them as the dividing line between junior and senior SQL. Every problem here is Hard for a reason - master PARTITION BY and frame semantics and the rest follows.
9 problems across 4 schemas · Premium. Each runs your query in an isolated SQLite sandbox with instant, graded feedback.
A quick data question to warm up before you write SQL. No signup needed.
Product data arrives in three normalised source tables: product, subcategory and category. The reporting model needs a single product dimension, and a product's category history must be kept when it changes. How should the data be prepared?
Keep the syntax at your fingertips with the free SQL quick references, then come back and solve.