Skip to content
All courses
SQLBeginner

SQL Fundamentals

Write your first database queries. Pick columns, filter and sort rows, summarise data with counts and totals, and join tables together, using a practice database for an online shop and a learning platform.

Free to browse. You sign in at the first lesson so your progress is saved.

What you will be able to do

  • Write SELECT queries that return exactly the columns and rows you need
  • Filter rows with WHERE, AND, OR, IN, BETWEEN, LIKE and IS NULL
  • Sort and tidy results with ORDER BY, LIMIT, DISTINCT and column aliases
  • Summarise data with COUNT, SUM, AVG, MIN, MAX and GROUP BY
  • Combine two or three tables with INNER JOIN

Syllabus

5 modules and 24 lessons. Each lesson is a short read followed by an exercise with tests.

Module 1

Your first queries

Read a table, choose columns and filter rows with WHERE.5 lessons, about 54 min
  1. 1Tables, rows and columnsWhat a database is, and how to see everything in a table.10 min
  2. 2Choosing columnsAsk for only the columns you need, in the order you want.10 min
  3. 3Filtering rows with WHEREKeep only the rows that match a condition.12 min
  4. 4Comparing numbersFind rows above, below or not equal to a value.12 min
  5. 5Matching textFilter on words and names using quotes.10 min
Module 2

Combining conditions

Ask sharper questions with AND, OR, IN, BETWEEN, LIKE and NULL checks.5 lessons, about 1 hour
  1. 6AND, OR and NOTCombine several conditions in one WHERE clause.15 min
  2. 7Matching a list with INCheck a value against several options at once.10 min
  3. 8Ranges with BETWEENFind values that fall inside a range, including dates.10 min
  4. 9Searching text with LIKEMatch patterns in text with wildcards.12 min
  5. 10Missing values and NULLFind, and avoid losing, rows with unknown values.15 min
Module 3

Sorting and shaping results

Put rows in order, take the top few, remove duplicates and calculate new columns.4 lessons, about 47 min
  1. 11Sorting with ORDER BYSort results by one or more columns, up or down.12 min
  2. 12Top results with LIMITReturn only the first few rows of a sorted result.10 min
  3. 13Removing duplicates with DISTINCTList each different value once.10 min
  4. 14Calculated columns and aliasesDo arithmetic in a query and give the result a clear name.15 min
Module 4

Summarising data

Count, total, average and group rows to answer "how many" and "how much".5 lessons, about 57 min
  1. 15Counting rows with COUNTTurn many rows into one number.10 min
  2. 16Counting different valuesUse COUNT(DISTINCT ...) and several counts in one query.10 min
  3. 17Totals and averages with SUM and AVGAdd up a column, or find its average.12 min
  4. 18Smallest and largest with MIN and MAXFind the lowest and highest values in a column.10 min
  5. 19Grouping with GROUP BYGet a count or total for each group, in one query.15 min
Module 5

Joining tables

Combine rows from two or three related tables with INNER JOIN.5 lessons, about 1 hour
  1. 20Joining two tablesMatch rows across tables using a shared id.15 min
  2. 21Joining three tablesUse a linking table to connect two others.15 min
  3. 22Filtering a joinAdd WHERE to a join to keep only the rows you need.12 min
  4. 23One person's recordsFilter a join by a name held in another table.12 min
  5. 24Joins with totalsCombine joins, calculations and GROUP BY to total each order.20 min

After this course

Where to go next

These courses build on what you learn in SQL Fundamentals.

  • SQLIntermediate

    Database Design and Data Changes

    Change data safely, then design, link and tune your own tables in SQLite.

    Recommended first: SQL Fundamentals

    • 22 lessons
    • About 5 hours
  • SQLIntermediate

    SQL for Data Analysis

    Answer real business questions with SQL: summarise and join data with confidence, handle missing values, and use subqueries, CTEs and window functions on a small UK online shop.

    Recommended first: SQL Fundamentals

    • 24 lessons
    • About 6 hours