What you'll learn

Twenty lessons, zero to confident

Each lesson is short and hands-on, building on the last. You'll go from your very first SELECT to joins, subqueries, and window functions — every example ready to run in SQL Server, MySQL, and PostgreSQL.

Foundations

  • 1

    What is SQL?

    What a database is, what SQL does, and how to think about talking to your data.

  • 2

    Database Structure

    Tables, columns, rows, and keys — how to read a database diagram and see how tables relate.

Asking questions of your data

  • 3

    Retrieving Data

    Your first SELECT: pull columns, get distinct values, and limit how many rows come back.

  • 4

    Filtering

    Narrow results with WHERE — exact matches, comparisons, LIKE, IN, and combining conditions.

  • 5

    Sorting Data

    Order results with ORDER BY, ascending or descending, across one or more columns.

  • 6

    Joins

    Combine related tables with inner and outer joins — and know exactly which rows come back.

  • 7

    Manipulating Data and Aliases

    Calculate new columns, build readable output, and give columns friendly names with aliases.

  • 8

    Functions

    Put built-in functions to work: COUNT, MIN, MAX, AVG, SUM, and more.

  • 9

    Window Functions

    Rank and number rows and look across them with ROW_NUMBER, RANK, PARTITION BY, and LAG.

  • 10

    Summarizing Data

    Group rows with GROUP BY and filter groups with HAVING to turn detail into totals.

  • 11

    Subqueries

    Use one query inside another to answer questions a single query can't.

Changing data & building objects

  • 12

    Inserting Data

    Add new rows to a table with INSERT, safely and predictably.

  • 13

    Making Changes to Data

    Update and delete existing records with confidence — and avoid the classic mistakes.

  • 14

    Creating Objects

    Create your own tables and other database objects from scratch.

  • 15

    Views

    Save a query as a reusable view to simplify the questions you ask most.

  • 16

    Security

    The essentials of who can see and do what inside a database.

  • 17

    Changing Objects

    Alter tables and objects as your needs change, without starting over.

Building your own tables? See the reference on auto-incrementing primary keys — one for each database.

Going further

  • 18

    Data Types

    Choose the right type for each column and understand how databases store your data.

  • 19

    Advanced Features

    A tour of the more powerful tools you'll reach for as you grow.

  • 20

    Working with Dates

    Handle dates and times — often the trickiest part of real-world data — with confidence.

Learn by doing

Follow every lesson with free scripts

Download the practice database and every example query, ready to run in all three databases.

Browse the free scripts →