Skip to content

SQL For Data Analysis Textbook

A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 120 companion flashcards using spaced repetition.

7 chapters · 120 cards · Updated

Chapters

  1. 1Foundations of SELECT

    SQL, or Structured Query Language, is the standard language for querying and manipulating relational data. At its core, every data-retrieval query begins with the SELECT statement,...

  2. 2Joining Tables

    Joins are how you combine rows from multiple related tables, and choosing the right join type determines which rows appear in the output. An INNER JOIN returns only rows with match...

  3. 3Aggregating and Grouping Data

    Aggregation compresses many rows into summary values. The standard aggregate functions are COUNT, SUM, AVG, MIN, and MAX; COUNT totals the number of rows (or non-NULL values in a s...

  4. 4Window Functions

    Window functions perform calculations across a set of rows that are related to the current row, but unlike aggregates they do not collapse the result set — every input row still ap...

  5. 5Subqueries, CTEs, and Set Operations

    A subquery is a query nested inside another query — in SELECT, FROM, WHERE, or HAVING — and provides a way to compute a value or set of values that the outer query then uses. A non...

  6. 6Operators, Expressions, and Type Handling

    Beyond the basic comparison operators, SQL offers specialized tools for working with strings, ranges, and conditional logic. The LIKE operator performs pattern matching on string c...

  7. 7Schema, Performance, and Data Integrity

    Indexes are data structures — typically B-trees — that speed up lookups at the cost of additional storage and slower writes. A clustered index determines the physical order of data...

← Back to the SQL For Data Analysis deck