Learn SQL
A structured path from your first SELECT to advanced SQL. Every lesson includes a live, in-browser database to practice against.
Beginner
beginner4 min
Introduction to SQL
What SQL is, why it matters, and how you'll learn it in this course.
beginner4 min
The SELECT Statement
How to choose exactly which columns you want back from a table using SELECT.
beginner5 min
Filtering Rows with WHERE
Use the WHERE clause and comparison operators to filter which rows a query returns.
beginner4 min
Removing Duplicates with DISTINCT
Use DISTINCT to see the unique values in a column, without repeats.
beginner5 min
Sorting Results with ORDER BY
Control the order of your query results with ORDER BY, ascending or descending, across one or more columns.
beginner4 min
Limiting Results with LIMIT
Use LIMIT to cap how many rows a query returns, and OFFSET to skip ahead in the results.
beginner4 min
Renaming Output with Aliases
Use AS to give columns and tables friendlier, more readable names in your query results.
beginner5 min
Arithmetic in SELECT
Perform calculations directly in your queries using +, -, *, and / to create computed columns.
beginner5 min
Understanding NULL
What NULL means in SQL, how it differs from zero or an empty string, and how to test for it correctly.
beginner5 min
Pattern Matching with LIKE
Search for partial text matches using the LIKE operator and its % and _ wildcards.
beginner4 min
Matching Multiple Values with IN
Use the IN operator to cleanly match a column against a list of possible values.
beginner4 min
Range Matching with BETWEEN
Use the BETWEEN operator to filter values that fall within an inclusive range of numbers or dates.
Intermediate
intermediate6 min
GROUP BY
Collapse rows into groups so you can summarize data with aggregate functions like COUNT, SUM, and AVG.
intermediate5 min
HAVING
Filter groups after aggregation — the GROUP BY equivalent of WHERE.
intermediate6 min
INNER JOIN
Combine rows from two tables where a related key matches on both sides.
intermediate6 min
LEFT JOIN
Keep every row from the left table, matching rows from the right table when available — filling gaps with NULL.
intermediate5 min
RIGHT JOIN
Keep every row from the right table and match rows from the left when available.
intermediate6 min
FULL JOIN
Keep every row from both tables, matching where possible and filling NULLs on either side.
intermediate5 min
UNION
Stack the results of two or more queries with matching columns into a single result set.
intermediate6 min
CASE Expressions
Add if/else logic directly inside a query to label, bucket, and transform values on the fly.
intermediate6 min
Aggregate Functions
Summarize many rows into a single number with COUNT, SUM, AVG, MIN, and MAX.
intermediate7 min
Subqueries
Nest one query inside another to compute values you can use in WHERE, FROM, or SELECT.
Advanced
advanced6 min
Common Table Expressions (CTE)
Name a query with WITH so you can reference it like a temporary table and write cleaner SQL.
advanced7 min
Recursive CTEs
Use WITH RECURSIVE to walk hierarchies and sequences like org charts and numbered lists.
advanced8 min
Window Functions
Compute running totals, ranks, and per-group comparisons without collapsing rows like GROUP BY does.
advanced6 min
Indexes
Speed up lookups with database indexes — what they are, when to add them, and their trade-offs.
advanced7 min
Query Optimization
Write queries the planner can execute efficiently — read less data, use indexes, and avoid surprises.
advanced6 min
Transactions
Group multiple statements into an all-or-nothing unit with BEGIN, COMMIT, and ROLLBACK.
advanced5 min
Views
Save a query as a named, reusable virtual table with CREATE VIEW.
advanced6 min
Stored Procedures
Package reusable SQL logic on the server with parameters, branching, and transactions.
advanced6 min
Triggers
Automatically run SQL in response to INSERT, UPDATE, or DELETE events on a table.
advanced6 min
EXISTS and NOT EXISTS
Test whether a subquery returns any rows — a fast, set-based way to filter.
advanced5 min
INSERT
Add new rows to a table with INSERT INTO — single rows, multiple rows, and from a query.
advanced5 min
UPDATE
Modify existing rows in a table with UPDATE — change one column or many, for one row or millions.
advanced5 min
DELETE
Remove rows from a table with DELETE — scoped by WHERE, or wipe a table entirely.
advanced6 min
String Functions
Transform and inspect text with UPPER, LOWER, LENGTH, CONCAT, SUBSTRING, and more.
advanced6 min
Date and Time Functions
Work with dates using EXTRACT, DATE_TRUNC, intervals, and date arithmetic.
advanced6 min
Self Joins
Join a table to itself to compare rows within the same table, like employees and their managers.
advanced5 min
Cross Joins
Produce every combination of rows from two tables with CROSS JOIN.
advanced5 min
EXCEPT and INTERSECT
Compare result sets: keep rows in one but not another (EXCEPT), or only the shared rows (INTERSECT).