SQLSQL

Learn SQL – all lessons

15 lessons from beginner to advanced, building on each other and with code examples.

Beginner
1

SELECT & FROM – Querying Data

Choosing columns, renaming, calculating, and removing duplicates.

2

WHERE – Filtering Rows

Conditions, operators, LIKE, IN, BETWEEN, and dealing with NULL.

3

ORDER BY, LIMIT & OFFSET

Sorting results, fetching the first n rows, and paging.

4

Aggregate Functions, GROUP BY & HAVING

Summarizing rows: counting, summing, grouping, and filtering groups.

5

INSERT, UPDATE & DELETE

Inserting, changing, and deleting data – and why WHERE is vital.

Intermediate
6

JOINs – Combining Tables

INNER, LEFT, anti-joins, self-joins, and multi-table joins.

7

Subqueries, EXISTS & Set Operations

Nesting queries, correlated subqueries, UNION, and friends.

8

CREATE TABLE, Data Types & Constraints

Defining tables and enforcing data quality through the schema.

9

CASE, NULL Handling & Functions

Conditional values, COALESCE, text, number, and date functions including dialect differences.

10

Transactions & ACID

Executing multiple changes atomically – COMMIT, ROLLBACK, SAVEPOINT.

Advanced
11

CTEs & Recursive Queries

Structuring complex queries with WITH, generating hierarchies and number sequences.

12

Window Functions

Rankings, running totals, and comparisons with preceding rows – without collapsing groups.

13

Indexes & Query Plan (EXPLAIN)

Why queries are slow and how B-tree indexes help.

14

Database Design & Normalization

Avoiding redundancy: 1NF, 2NF, 3NF, relationships, and when to denormalize deliberately.

15

Views, UPSERT, RETURNING & Security

Reusable views, insert-or-update, return values, and protection against SQL injection.