Learn SQL – all lessons
15 lessons from beginner to advanced, building on each other and with code examples.
SELECT & FROM – Querying Data
Choosing columns, renaming, calculating, and removing duplicates.
WHERE – Filtering Rows
Conditions, operators, LIKE, IN, BETWEEN, and dealing with NULL.
ORDER BY, LIMIT & OFFSET
Sorting results, fetching the first n rows, and paging.
Aggregate Functions, GROUP BY & HAVING
Summarizing rows: counting, summing, grouping, and filtering groups.
INSERT, UPDATE & DELETE
Inserting, changing, and deleting data – and why WHERE is vital.
JOINs – Combining Tables
INNER, LEFT, anti-joins, self-joins, and multi-table joins.
Subqueries, EXISTS & Set Operations
Nesting queries, correlated subqueries, UNION, and friends.
CREATE TABLE, Data Types & Constraints
Defining tables and enforcing data quality through the schema.
CASE, NULL Handling & Functions
Conditional values, COALESCE, text, number, and date functions including dialect differences.
Transactions & ACID
Executing multiple changes atomically – COMMIT, ROLLBACK, SAVEPOINT.
CTEs & Recursive Queries
Structuring complex queries with WITH, generating hierarchies and number sequences.
Window Functions
Rankings, running totals, and comparisons with preceding rows – without collapsing groups.
Indexes & Query Plan (EXPLAIN)
Why queries are slow and how B-tree indexes help.
Database Design & Normalization
Avoiding redundancy: 1NF, 2NF, 3NF, relationships, and when to denormalize deliberately.
Views, UPSERT, RETURNING & Security
Reusable views, insert-or-update, return values, and protection against SQL injection.