ShareYourGroupShareYourGroupSQL

All SQL lessons, in order

Twenty-six lessons in five stages. Each lesson takes fifteen to thirty minutes with its exercises and ends with a link to the next.

Reading data

Summaries

More than one table

Changing data and tables

Going further

How the stages fit together

Reading data is nine lessons on SELECT: choosing columns, filtering rows with WHERE, searching text, handling missing values, sorting and limiting. Reading never changes anything, so it is the safe place to build confidence. By the end you can answer most questions about a single table.

Summaries turns rows into figures. Functions tidy up values, the five aggregate functions count and add, and GROUP BY with HAVING produces a figure for each category, city or month. This is the stage where SQL starts to replace a spreadsheet.

More than one table is the centre of the course. Real data is spread across tables, and joins bring it together. Take these five lessons slowly. LEFT JOIN and the idea of "rows with no match" confuse nearly everyone at first, and then become second nature.

Changing data and tables covers INSERT, UPDATE, DELETE, creating tables with proper types and rules, altering them, and indexes. The lesson on UPDATE and DELETE includes a safety routine that is worth learning by heart.

Going further has the tools that make hard questions easy: CASE for conditions, date handling, views and WITH for building a query in steps, and window functions for ranking and running totals.

Tips for steady progress

This is an independent learning site. It is not connected with the makers of any database product. MySQL, PostgreSQL, SQL Server, Oracle and SQLite are named only so that you know where a piece of SQL works. The shop, its customers and its staff in the practice database are made up.