Table of Contents
The Chapters
Twelve self-contained chapters. Each opens with a short orientation and a numbered list of queries, easy through advanced.
- 01
Advanced PostgreSQL
Beyond the standard surface. JSONB, arrays, full-text search, partitions, and the features that make Postgres feel limitless.
350 queries · 5 easy · 163 intermediate · 182 advanced
- 02
Basic SELECT
The foundation. Selecting columns, ordering, limiting, and counting — the vocabulary every query is built from.
136 queries · 71 easy · 55 intermediate · 10 advanced
- 03
CTEs & Recursive
Common table expressions. Named building blocks, recursion, and the readable alternative to nested subqueries.
15 queries · 3 easy · 4 intermediate · 8 advanced
- 04
Date & Time Functions
Time, done properly. Intervals, truncation, extraction, time zones, and the arithmetic that survives DST.
16 queries · 6 easy · 5 intermediate · 5 advanced
- 05
GROUP BY & Aggregation
Folding rows into summaries. GROUP BY, HAVING, ROLLUP, and the aggregate functions that turn data into answers.
24 queries · 7 easy · 10 intermediate · 7 advanced
- 06
INSERT, UPDATE, DELETE
Changing data safely. INSERT, UPDATE, DELETE, UPSERT, RETURNING, and the patterns that keep history intact.
15 queries · 6 easy · 5 intermediate · 4 advanced
- 07
JOINs (INNER, LEFT, RIGHT, FULL)
Combining tables. Inner, left, right, full, self, and the cross — knowing which one to reach for is most of the craft.
32 queries · 10 easy · 11 intermediate · 11 advanced
- 08
Performance & Indexes
Making queries fast. Indexes, EXPLAIN, statistics, partial and expression indexes, and reading a plan without flinching.
76 queries · 4 easy · 8 intermediate · 64 advanced
- 09
String Functions
Text in Postgres. Concatenation, casing, trimming, regex, and the functions that quietly do most of the work.
19 queries · 7 easy · 7 intermediate · 5 advanced
- 10
Subqueries & EXISTS
Queries inside queries. Scalar, correlated, EXISTS, IN, ANY, ALL — and when a CTE would read better.
21 queries · 7 easy · 7 intermediate · 7 advanced
- 11
WHERE & Filtering
Narrowing the result set. Predicates, boolean logic, pattern matches, null handling, and the small operators that change everything.
30 queries · 12 easy · 12 intermediate · 6 advanced
- 12
Window Functions
Looking sideways without collapsing rows. Partitioning, ordering, running totals, ranks, leads, and lags.
22 queries · 6 easy · 8 intermediate · 8 advanced