Curriculum

From your first SELECT
to window functions.

Six courses built around real Postgres sandboxes. Read a short lesson, write the query, see your result graded in milliseconds.

6
courses
25
lessons
86
exercises
Start here

SQL Fundamentals

Write your first real queries — pick columns, filter rows, sort results, and limit output. The four moves you will use in every query you ever write.

5 lessons19 exercises~63 min
Begin the course →

Continue the path

Hand-picked order
Beginner
02

Filtering & Logic

Stop returning too many rows. Master WHERE clauses with AND, OR, LIKE, IN, BETWEEN, and NULL handling — the difference between a query that works and one that almost works.

Builds on: SQL Fundamentals

What you'll learn

  • Master AND / OR / NOT logic
  • Use IN, BETWEEN, LIKE, IS NULL
  • Build multi-condition filters
HR Database14 exercises to complete
4 lessons14 exercises~48 min
Start →
Intermediate
03

Aggregations & Grouping

Turn thousands of rows into meaningful numbers. COUNT, SUM, AVG, GROUP BY, and HAVING power every dashboard and business report you will ever build.

Builds on: Filtering & Logic

What you'll learn

  • COUNT, SUM, AVG, MIN, MAX
  • Group rows with GROUP BY
  • Filter groups using HAVING
Store Database14 exercises to complete
4 lessons14 exercises~48 min
Start →
Intermediate
04

Joins

Query multiple tables at once. Master INNER, LEFT, RIGHT, and FULL OUTER joins — and finally understand which rows appear in your result and why.

Builds on: Aggregations

What you'll learn

  • INNER, LEFT, RIGHT & FULL joins
  • Join tables on matching keys
  • Multi-table queries
HR Database14 exercises to complete
4 lessons14 exercises~48 min
Start →
Intermediate
05

Subqueries & CTEs

Break hard questions into readable steps. Subqueries and WITH blocks let you compose multi-stage logic that would be impossible — or unreadable — in a single query.

Builds on: Joins

What you'll learn

  • Scalar & correlated subqueries
  • Build reusable CTEs with WITH
  • Nested query logic
Store & HR databases13 exercises to complete
4 lessons13 exercises~46 min
Start →
Advanced
06

Window Functions

The most powerful feature in SQL — and the most asked-about in data interviews. Rank rows, run totals, and compare each row to its neighbors without collapsing your result set.

Builds on: Subqueries & CTEs

What you'll learn

  • RANK, ROW_NUMBER, DENSE_RANK
  • Running totals with SUM OVER
  • LAG, LEAD & NTILE
HR Database12 exercises to complete
4 lessons12 exercises~44 min
Start →

Deep practice packs

Extra guided exercises per course to strengthen mastery.

Open playground →

SQL Fundamentals

3 bonus lessons • 10 bonus exercises

Executive employee list

Easy

Return first_name, last_name, salary from employees with explicit ORDER BY and LIMIT 20.

Column precision drill

Easy

Return exactly 4 requested columns from employees and rename two with business aliases.

Deterministic top earners

Medium

Return top 15 salaries with tie-break order by employee_id.

Unique department list

Easy

Return distinct department_id values sorted ascending.

Clean contact extract

Medium

Return employee contact columns and normalize output column names with aliases.

Reproducible paging

Medium

Return rows 21-40 using LIMIT/OFFSET with stable ordering.

Salary band snapshot

Medium

Return employees with salary, plus a derived salary_band CASE expression.

QA preview view

Easy

Build a compact preview query that verifies table shape and data quality.

Sort audit

Hard

Demonstrate two different deterministic ordering strategies and compare outputs.

Readable SQL rewrite

Medium

Refactor a messy SELECT into clean formatting with clear aliases.

Filtering & Logic

3 bonus lessons • 10 bonus exercises

Eligibility filter

Easy

Filter employees by department, salary floor, and hire date threshold.

Compliance exclusion

Medium

Exclude rows by multi-rule policy with grouped OR conditions.

Date-range hiring set

Medium

Return hires within a target month range with explicit boundaries.

Null-safe contact check

Medium

Return employees missing email/phone with clear null logic.

Pattern targeting

Easy

Find employee emails with specific domain patterns and case handling.

NOT logic challenge

Medium

Rewrite a complex negative filter into a readable positive equivalent.

Range segmentation

Hard

Classify rows into compensation ranges and filter by selected segments.

Multi-policy filter

Hard

Implement three business policies in one WHERE clause with comments.

Set inclusion audit

Easy

Use IN/NOT IN safely and explain null pitfalls in output notes.

Filter correctness test

Medium

Run count checks before/after each condition to prove logic correctness.

Aggregations & Grouping

3 bonus lessons • 10 bonus exercises

Department headcount

Easy

Return headcount per department with deterministic ordering.

Compensation KPI table

Medium

Return avg, min, max salary per department with readable aliases.

High-performing groups

Medium

Keep only groups above salary or volume thresholds using HAVING.

Distinct employee coverage

Easy

Compare COUNT(*) vs COUNT(DISTINCT employee_id) by group.

Revenue rollup by category

Hard

Build category revenue totals with grouped order metrics.

KPI quality audit

Medium

Add count-based quality checks next to each aggregate metric.

Bucketed aggregation

Hard

Group rows by computed range bucket and aggregate each bucket.

Multi-metric dashboard

Hard

Return 6+ aggregate metrics in one compact management table.

Aggregation sanity check

Easy

Validate expected number of groups and total row coverage.

Filtered aggregate pattern

Medium

Use FILTER (WHERE ...) for conditional aggregates.

Joins

3 bonus lessons • 10 bonus exercises

Employee-department map

Easy

Join employees to departments with clear aliases and deterministic sorting.

Department coverage left join

Medium

Keep all departments and include employee counts including zero-member groups.

Three-table staff view

Medium

Join employees, departments, and jobs in one clean result set.

Missing-relationship audit

Medium

Identify records with no matching lookup table rows.

Join multiplication defense

Hard

Prevent duplicates by pre-aggregating line-item table before join.

Store order expansion

Hard

Join orders, customers, and order_items with quality-safe counts.

Hospital appointment graph

Medium

Join appointments to doctors and patients for operational reporting.

Join type comparison

Easy

Compare INNER vs LEFT row counts and explain differences.

Key mismatch detector

Hard

Create a query that flags suspicious foreign-key gaps across tables.

Production-ready join report

Hard

Deliver a final join report with row-quality validation columns.

Subqueries & CTEs

3 bonus lessons • 10 bonus exercises

Above-average salary markers

Easy

Use subquery to flag employees above global average salary.

Department benchmark filter

Medium

Use correlated subquery against department-level average.

Two-stage CTE pipeline

Medium

Build a CTE chain for cleaned base rows and final summary output.

Top-customer CTE

Hard

Return top spenders using staged CTE logic from orders and items.

EXISTS eligibility check

Medium

Use EXISTS to keep only rows with qualifying related records.

Nested query rewrite

Hard

Refactor nested subquery into cleaner CTE architecture.

CTE debugging drill

Easy

Run each CTE stage independently and validate intermediate row counts.

Derived table comparison

Medium

Compare derived table approach with CTE approach for same business question.

Multi-rule analysis pipeline

Hard

Create a 3+ stage analysis pipeline with explicit business-rule stages.

Reusable CTE view pattern

Hard

Design a repeatable CTE template for recurring KPI requests.

Window Functions

3 bonus lessons • 10 bonus exercises

Salary rank per department

Easy

Rank salaries within each department using PARTITION BY.

Dense ranking variation

Medium

Compare RANK and DENSE_RANK outputs for tied salaries.

Running revenue total

Medium

Compute running totals by order date and customer.

Previous period delta

Hard

Use LAG to calculate period-over-period change percentage.

Top-N per group

Hard

Return top 3 earners per department using window filtering.

Hire timeline sequence

Easy

Use ROW_NUMBER to sequence hires by department and date.

Moving average trend

Hard

Compute rolling 3-period average with explicit frame clause.

Quartile segmentation

Medium

Use NTILE(4) to segment salaries into quartiles.

First/last value drill

Medium

Use FIRST_VALUE and LAST_VALUE in partitioned windows.

Window quality audit

Hard

Validate partition sizes and ranking consistency in final output.

Built from learner feedback

What learners asked for, now built in

Thea

I wanted clear tasks I could complete in sequence, then repeat with confidence. Joins were still the hardest part.

Sarita

I needed logical reasoning and plain-language explanations for each command so I could remember it long term.

Transparent tasks

Every lesson and challenge has explicit goals, expected output shape, and practical context.

Reasoning-first explanations

We teach the logic behind SQL clauses, not just syntax, so learners can apply patterns in real work.

Repeatable completion loops

Learners can re-run exercises, guided hints, and challenge levels to reinforce skills quickly.