01TOOL PATH · SQL

SQL for Analysis

Answer business questions with SQL, from your first query to finding why a number moved. Every exercise runs in your browser on the data of Raket Parts, a fictional maker of rocket parts. For clear examples, see JOIN double-counting and GROUP BY and HAVING.

You will be able to

  • write queries that pick the right rows
  • count and sum without double counting
  • join tables safely
  • explain why a figure changed
Start module 15 of 12 modules open · nothing to install
01

Your first queries

Read how company data is stored, then write SELECT, WHERE, ORDER BY and DISTINCT queries.

Not started
02

What one row means

Find the key, prove the grain and spot history rows before you count anything.

Not started
03

Choosing the right rows

NULL, blanks, cancelled records and date boundaries, so you count the right population.

Not started
04

Counting and summing correctly

COUNT, GROUP BY, HAVING, shares of total and matching the finance figure.

Not started
05

Joining tables safely

INNER and LEFT joins, and how to stop a join doubling your totals.

Not started
06

Finding what is missing

Anti-joins, UNION and EXCEPT, and reconciling two sources.

Coming soon
07

Building in steps

Subqueries and CTEs, each step checked by a count.

Coming soon
08

Dates and time

Months, quarters, time zones and like-for-like comparisons.

Coming soon
09

Window functions

Ranking, running totals, LAG and LEAD.

Coming soon
10

Sequences and cohorts

Ordering events, time in a state and retention.

Coming soon
11

Diagnosing wrong results

Find why a number is wrong, ending with the €2.6m sales question.

Coming soon
12

Reusable SQL

Views, and four tests to run before anyone else uses your query.

Coming soon

Want to practice on your own questions? The free SQL practice page has the same tables and ten starter questions.

Open free SQL practice