SkillByAIOpen interactive version →

SQL Deep Dive

Go beyond SELECT * : how SQL evaluates queries, joins without surprises, window functions, recursive CTEs, analytical patterns and index-friendly queries, with every query run on PostgreSQL 16.

Start course →

What you'll learn

Syllabus

How SQL Thinks

  1. Thinking in Sets
  2. Logical Order of Evaluation
  3. NULL and Three-Valued Logic

Joins Without Surprises

  1. Inner and Outer Joins
  2. Semi-Joins and Anti-Joins
  3. Fan-Out and Double Counting

Aggregation and Reporting

  1. GROUP BY, HAVING and FILTER
  2. Subtotals With ROLLUP and GROUPING SETS
  3. Pivoting With Conditional Aggregation

Window Functions

  1. Ranking and Top-N per Group
  2. Running Totals, Moving Averages and LAG
  3. Shares, Comparisons and Bands

CTEs, LATERAL and Set Operations

  1. CTEs and Recursive Queries
  2. LATERAL Joins
  3. UNION, INTERSECT and EXCEPT

Analytical Patterns

  1. Filling Gaps in Time Series
  2. Gaps and Islands
  3. Finding and Removing Duplicates

Changing Data Safely

  1. MERGE and Upserts
  2. UPDATE ... FROM and DELETE ... USING
  3. A Safe Workflow for Data Changes

Writing Fast Queries

  1. Index-Friendly (Sargable) Predicates
  2. Composite Index Column Order
  3. Reading EXPLAIN ANALYZE
  4. An SQL Review Checklist