Engineer Atlas
OverviewLearnInternalsModeling LabPlaygroundDatabase FinderRoadmapPracticeInterview
OverviewLearnInternalsModeling LabPlaygroundDatabase FinderRoadmapPracticeInterviewCheat SheetCompare
Database Engineering
  • Database Fundamentals
  • SQL
  • Relational Modeling
  • Normalization & Denormalization
  • Indexes
  • Query Execution & Optimization
  • Transactions
  • Concurrency & Isolation
  • PostgreSQL
  • Redis
  • NoSQL & Data Models
  • Vector Databases & Retrieval
  • Scaling
  • Distributed Databases
  • Caching
Database Internals
  • Overview
  • Build AtlasDB
  • Storage, Records & Pages
  • Index Internals
  • Buffer Management
  • WAL & Recovery
  • Transactions & MVCC Internals
  • LSM Trees
  • Query Engine
  • PostgreSQL & InnoDB Internals
  • Distributed Internals
  • Performance Internals
Database/Learn/SQL
Database Engineering

SQL

From SELECT to window functions: filtering, aggregation, every join, subqueries, CTEs and the NULL rules that trip everyone up.

See how this works internally:Query Engine →
SELECT, FROM, WHERE, ORDER BY, LIMIT
▶ interactive

A SELECT is evaluated FROM → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT; write it in that order in your head and half of SQL’s "surprises" disappear.

Aggregation: COUNT, SUM, AVG, GROUP BY, HAVING

GROUP BY collapses many rows into one per group; aggregates summarise each group; HAVING filters groups after they exist — and the most common aggregation bug is a join that multiplied the rows before you summed them.

Joins: INNER, LEFT, RIGHT, FULL, CROSS, SELF
▶ interactive

A join pairs rows from two tables on a condition; the join type decides what happens to rows with no partner, and where you put a condition — ON or WHERE — decides whether an outer join stays outer.

Subqueries, CTEs, EXISTS, UNION, CASE

A subquery is a query used as a value, a list or a table; a CTE names one; EXISTS asks "is there at least one"; and the difference between a correlated and an uncorrelated subquery is the difference between one execution and one per row.

Window Functions
▶ interactive

A window function computes a value for each row from a set of related rows — rank, running total, previous value — without collapsing the rows the way GROUP BY does.

Engineer Atlas
GitHub·LinkedIn