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
- Run every example, and change it before you move on. Guess the result first.
- Do the exercises in the practice box. The check is strict about rows and relaxed about how you wrote the query.
- When a query fails, read the error message. It nearly always names the word that is wrong.
- Keep the practice database page open in another tab while you work, so that you can see the table and column names.
- After the lessons, test yourself on the full list of exercises and the interview questions.
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.