Course

SQL from the ground up

Ask the data a question

  • Beginner
  • 12 chapters
  • 183 min read

A hands-on first course in SQL, from your first SELECT to a small report built from joins and grouping: every idea comes with a real database in the browser, with a short quiz at the end of each chapter.

What You'll Learn

  • Read and write SELECT queries with confidence
  • Filter rows, sort them, and take just a few
  • Match patterns, ranges and missing values
  • Count, sum and average with grouping
  • Join tables and know which rows stayed out
  • Add, change and delete rows safely
  • Design a small schema with the right constraints
  • Write a report with subqueries, CASE and labels

Prerequisites

  • No programming experience needed; the course starts at the first query
  • Curiosity about where data lives — everything else is taught here

Vocabulary

The terms the chapters assume, in plain words.

alias
A short second name given to a table or column in a query, so the rest of the query can refer to it briefly.
Cartesian product
Every row of one table paired with every row of another, which happens when a join has no matching rule.
column
One named field in a table, with the same kind of value in every row, such as a title or a year.
constraint
A rule a table enforces on its data, such as requiring a value or making one column unique.
distinct
A word in a query that removes repeated rows from the result, so each one appears once.
foreign key
A column that refers to the primary key of another table, so each row can be tied to one row there.
index
A stored lookup that helps the database find rows quickly without reading the whole table.
inner join
The default way of combining two tables: only pairs of rows present on both sides appear in the result.
join
A query operation that combines rows from two tables by matching values they share, usually a shared identifier.
junction table
A bridge between two tables that lets a row on either side pair with many on the other; each of its rows holds one pair.
left join
A combination that keeps every row of the first table named, filling in nulls where the second has no match.
many-to-many
A relationship where one row on each side can pair with many rows on the other, usually held in a junction table.
null
A marker for a value that is missing or unknown, which is not the same as zero or an empty string.
outer join
A join that keeps rows from one or both tables even when no row on the other side matches.
primary key
The column or columns that together identify each row uniquely, and which can never be missing.
query
A request written in SQL that asks the database for an answer, usually a table of rows.
row
One record in a table, with one value for each column that table defines.
schema
The stored plan of a database: its tables, the columns in each, and the rules those columns must follow.
table
A named set of rows that all share the same columns, such as one holding every book in a library.

Course Content

  1. 01
    How SQL works

    A database is tables of rows and columns, and SQL is how you ask them questions — one sentence that returns a table of answers.

    Beginner · 13 min read

    Not started
  2. 02
    Choosing columns, filtering rows

    The two halves of every query: which columns come back, and which rows make the cut — comparisons, AND, OR, and the parentheses that keep them honest.

    Beginner · 15 min read

    Not started
  3. 03
    Sorting and taking the top

    ORDER BY puts rows in the order you can read, LIMIT keeps only the first few, and why the two belong together whenever "the top" is what you are after.

    Beginner · 13 min read

    Not started
  4. 04
    Patterns, ranges and missing values

    LIKE for a pattern rather than a word, IN and BETWEEN for the two shapes a condition often takes, and the right way to ask about a value that is not there.

    Beginner · 15 min read

    Not started
  5. 05
    Counting and grouping

    Turning many rows into a few numbers: COUNT, SUM, AVG, MIN and MAX, the GROUP BY that gives each group its own answer, and HAVING for filtering the groups.

    Beginner · 16 min read

    Not started
  6. 06
    Joining tables

    Two tables, one key: INNER JOIN keeps the rows that match on both sides, LEFT JOIN keeps every row on the left, and aliases keep the query readable.

    Intermediate · 17 min read

    Not started
  7. 07
    Adding, changing, removing

    INSERT, UPDATE and DELETE: the three statements that change what is stored, the WHERE clause they all need, and how to experiment safely.

    Intermediate · 14 min read

    Not started
  8. 08
    Designing a table

    CREATE TABLE column by column: the types that fit real data, and the constraints — PRIMARY KEY, NOT NULL, UNIQUE, DEFAULT — that keep it honest from the first row.

    Intermediate · 16 min read

    Not started
  9. 09
    Working with text and numbers

    Functions that shape each row as it comes back: upper, lower and length, joining text with the double pipe, and rounding numbers that came out of arithmetic.

    Intermediate · 15 min read

    Not started
  10. 10
    Queries inside queries

    A subquery answers one question and hands the answer to another query, and WITH gives that answer a name — the two habits that keep a harder question readable.

    Advanced · 16 min read

    Not started
  11. 11
    Labels and missing values

    CASE chooses a value per row — the if/else of SQL — and COALESCE gives a missing value a stand-in, which is how a report stays readable without a single blank cell.

    Advanced · 15 min read

    Not started
  12. 12
    A small report

    Everything at once: three tables joined, grouped and labelled — a report written the way reports are, one piece at a time and then combined.

    Advanced · 18 min read

    Not started