What you’ll learn
- Chapter 1Reading tables – What a database is and how you look into it with SELECT.
What is a table? · Your first query: SELECT * · Only certain columns · Sorting with ORDER BY · Only the first ones: LIMIT - Chapter 2Filtering with WHERE – Only the rows that meet a condition.
WHERE: selecting rows · Greater, smaller, not equal · AND and OR · LIKE, IN and BETWEEN · Empty values: NULL - Chapter 3Counting and summarising – COUNT, SUM, AVG and groups.
Counting with COUNT · Sum, average, minimum, maximum · Forming groups: GROUP BY · Filtering groups: HAVING · Removing duplicates: DISTINCT - Chapter 4Joining tables – Keys and JOIN.
Keys connect tables · INNER JOIN · LEFT JOIN · Boss: the learning analysis - Chapter 5Creating and changing data – CREATE TABLE, INSERT, UPDATE and DELETE.
Creating a table · Inserting rows: INSERT · Changing data: UPDATE · Deleting rows: DELETE - Chapter 6Workshop: pro queries – Subqueries, CASE and your own analyses.
A query inside a query · If-then with CASE - Chapter 7New tools for your own ideas – Understand new concepts, fill them in and use them yourself.
COALESCE: replacing missing minutes · UNION and UNION ALL · Text functions in a query - Chapter 8Level up: your next practice chapter – Understand four new building blocks in small steps and use them yourself.
BETWEEN: a range with limits · LIKE: searching names by a pattern · CASE: a readable category · Subquery: above average - Chapter 9Master chapter: how real programs are built – Five building blocks from real projects – explained, connected, filled in and written by you.
Aliases: short names in a JOIN · NOT IN: what is still missing · INTERSECT: in both results · EXCEPT: only in the first result · Average per course with ROUND - Chapter 10Planning tables properly – Required fields, unique values, default values and tables that grow with you.
NOT NULL: required fields · UNIQUE: no duplicates · DEFAULT: default values · ALTER TABLE: adding a column later · Boss: a table for course registrations - Chapter 11Getting more out of joins – Self-join, three tables, missing partners and all combinations.
Self-join: a table with itself · Connecting three tables · What is missing? LEFT JOIN with IS NULL · CROSS JOIN: all combinations · Boss: a report card from several tables - Chapter 12Pro analyses – EXISTS, pages, conditional counting, reshaping text and saving results.
EXISTS: are there matching rows? · Page by page: LIMIT and OFFSET · Counting conditionally with SUM(CASE …) · Reshaping values: REPLACE, CAST and || · Boss: an evaluation in a new table - Chapter 13Grouping in depth – Count distinct values, group across tables, collect names and filter groups with aggregates.
Counting distinct values: COUNT(DISTINCT) · Grouping across several tables · Collecting names with GROUP_CONCAT · HAVING with MAX and MIN · Boss: a statistic per level - Chapter 14NULL in detail – What NULL does when counting, calculating, replacing and sorting – and how to handle it safely.
COUNT(*) and COUNT(column) are different · Calculating with NULL · Fallback values with IFNULL · NULL when sorting · Boss: courses per person – including zero - Chapter 15Changing data precisely – Copy rows from a query, change them with CASE and subqueries, and delete precisely.
Copying with INSERT … SELECT · UPDATE with CASE · UPDATE with a subquery · Deleting precisely with a subquery · Boss: end of term - Chapter 16Python + SQL: a program talks to the database – With sqlite3 Python sends SQL to a database, processes the results and stores new data – safely with placeholders.
Python opens a database: sqlite3 · Looping over results and formatting them · Inserting safely: ? instead of + · Saving data: INSERT and commit · Boss: a report from the database - Chapter 17Python + SQL: evaluations and reports – SQL calculates inside the database, Python turns it into reports: single values, groups as a dictionary, joins, many rows at once.
Getting single values: fetchone · GROUP BY meets dict · Joining tables: JOIN from Python · Many rows at once: executemany · Boss: a course report with bars
Final project: Learning statistics database
Build a table of your own, fill it with data and analyse it with queries.
How it works
Every lesson starts with short explanation pages. Then you practise with multiple-choice questions, fill-in-the-gap tasks, putting code in order and writing your own code – with hints and instant feedback. Free, without ads, on phone, tablet and PC.