SQL Intermediate: Queries That Survive Real Data
Window functions, CTEs and schema design for tables other people also write to. You will join three tables without double counting, rank and total rows with window functions, design tables that protect themselves, and read a query plan to see why a query is slow. If you skip the checks on duplicates, time zones and concurrent changes, your queries will pass on test data and give wrong answers on real data.
Course access
-
Joins Beyond the Basics (empty)3Lessons · 25 min
-
Three-Table Joins Without Double Counting
Join customers, orders and items, see how a total on the one side is counted once per row on the many side, and fix it by aggregating first. After this, a three-table report adds up to a number you can prove.
10 min -
Subqueries, EXISTS and IN: Which One When
Use a scalar subquery, IN and EXISTS, and see why NOT IN breaks when the list contains NULL. After this, you can pick the form that says what you mean and does not drop rows by accident.
10 min -
-
-
Thinking in Sets (empty)3Lessons · 25 min
-
CTEs: Break a Long Query Into Named Steps
Rewrite a nested query as named steps with WITH, chain steps and learn when PostgreSQL runs a CTE once or inlines it. After this, a long query reads from top to bottom and you can test each step alone.
10 min -
UNION, INTERSECT and EXCEPT
Combine, overlap and subtract query results, and see how UNION removes rows and how NULL behaves in set operations. After this, you can answer questions like who bought in both months with one readable query.
10 min -
-
-
Windows and Dates (empty)3Lessons · 25 min
-
Window Functions: ROW_NUMBER, RANK and Running Totals
Number, rank and total rows without collapsing them into groups, using PARTITION BY, ORDER BY and the window frame. After this, you can add a rank, a running total or the previous row to a result in one pass.
10 min -
Dates, Times and Time Zones in PostgreSQL
Pick between date, timestamp and timestamptz, group by day or month with date_trunc, and see how the session time zone changes what you read. After this, a report by day means the same day for everyone.
10 min -
-
-
Schema Design That Holds (empty)3Lessons · 25 min
-
Normalization: Where to Split and Where to Stop
Split a messy table by the facts it repeats, then see why one copy of a price is sometimes the bug. After this, you can tell a table that needs splitting from one that should keep a deliberate copy.
10 min -
UNIQUE, CHECK and Foreign Key Actions
Add UNIQUE and CHECK rules across more than one column and choose what happens to child rows with ON DELETE. After this, the database refuses the bad rows instead of your application.
10 min -
-
-
Indexes and Transactions (empty)3Lessons · 25 min
-
Indexes and EXPLAIN: Why That Query Is Slow
Read a simple plan, see a sequential scan turn into an index scan and learn when an index is not used. After this, you can check a slow query with EXPLAIN before you add anything.
10 min -
Transactions and What Two Users Can See
Run two sessions side by side and see what each one reads, from uncommitted changes to row locks and a serialization error. After this, you know what another user can see while your transaction is open.
10 min -
-
-
Final Check: SQL Intermediate (empty)1Lessons · 15 min
-
About
Window functions, CTEs and schema design for tables other people also write to. You will join three tables without double counting, rank and total rows with window functions, design tables that protect themselves, and read a query plan to see why a query is slow. If you skip the checks on duplicates, time zones and concurrent changes, your queries will pass on test data and give wrong answers on real data.
- Responsible
- Christopher R
- Last Update
- 10/07/2026
- Completion Time
- 2 h 20 min
- Members
- 1
Reviews
Sign in to write a reviewComments
Sign in to commentNo comments yet.