SQL Course · 77 lessons · approx. 487 minutes

Learn SQL

Learn SQL with a real learning database in the browser: read, filter, count, join and change tables. Every query really runs and you see the result as a table.

  • Tables
  • SELECT
  • WHERE
  • ORDER BY
  • COUNT & GROUP BY
  • JOIN
  • INSERT, UPDATE, DELETE
  • COALESCE: replacing missing minutes
  • UNION and UNION ALL
  • Text functions in a query
  • BETWEEN: a range with limits
  • LIKE: searching names by a pattern
  • CASE: a readable category
  • Subquery: above average
  • 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
  • Planning tables properly
  • Getting more out of joins
  • Pro analyses
  • Grouping in depth
  • NULL in detail
  • Changing data precisely
  • Python + SQL: a program talks to the database
  • Python + SQL: evaluations and reports

What you’ll learn

  1. 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
  2. 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
  3. 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
  4. Chapter 4Joining tables – Keys and JOIN.
    Keys connect tables · INNER JOIN · LEFT JOIN · Boss: the learning analysis
  5. Chapter 5Creating and changing data – CREATE TABLE, INSERT, UPDATE and DELETE.
    Creating a table · Inserting rows: INSERT · Changing data: UPDATE · Deleting rows: DELETE
  6. Chapter 6Workshop: pro queries – Subqueries, CASE and your own analyses.
    A query inside a query · If-then with CASE
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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.

Learn SQL now