Runnable SQL practice

40 SQL analytics challenges with validated answers.

Practice cohorts, retention, window functions, revenue analysis, and data engineering SQL patterns with small datasets you can run locally.

challenge 001 validated
SELECT
  sex,
  passenger_class,
  COUNT(*) AS total_passengers,
  ROUND(100.0 * AVG(survived), 2) AS survival_rate_pct
FROM passengers
GROUP BY sex, passenger_class
ORDER BY sex, passenger_class;
40 challenge folders
100% snapshot-validated outputs
4 structured learning paths

Start here

Move from selection to review without losing context.

1

Pick a challenge

Use the finder to filter by skill area and difficulty, or jump straight into the first challenge.

Open Finder
2

Read it in the viewer

Open the prompt, schema, solution, and expected output without leaving the project site.

Open Viewer
3

Run it locally

Copy the SQL commands, compare against the validated snapshot, and inspect the source on GitHub.

Open Repository

Challenge finder

Pick a problem that matches the skill you want to practice.

Filter the challenge set by topic and difficulty, then open a readable viewer with the prompt, schema, solution, and expected output.

Study paths

Start where the skill gap is.

Analytics Foundations

Grouping, ranking, time-based aggregation, percent-of-total analysis, and customer-level metrics.

Retention and Cohorts

Monthly retention, cohort offsets, repeat behavior, retention matrices, and rolling trends.

Revenue and Growth

Daily revenue, date spines, Pareto analysis, month-over-month growth, and customer contribution share.

Data Engineering SQL

Renewal state logic, SCD Type 2 history, incremental loads, stockout risk, conversion windows, and payment reconciliation.

Validation

CI checks the answers, not just the syntax.

Each challenge has an expected.json snapshot. The validator executes the schema and solution in SQLite, then compares the actual result columns and rows against the expected output.

python scripts/validate_challenges.py

Contribute

Bring a realistic analytics question.

The roadmap lists challenge ideas for inventory, attribution, SaaS metrics, support operations, and data quality. Requests and small fixes are welcome when they keep the examples runnable and easy to review.