Module · 4 lessons

Summarizing Data with SQL

Use aggregate functions and GROUP BY to compute totals, averages, and summary statistics across a table or within groups.

At a glance

Level
Beginner
Lessons
4 lessons
Time to complete
1 week
Cost
Free forever · no sign-up

Welcome to Summarizing Data with SQL. So far you have learned how to pull rows out of a table and filter them with WHERE. That answers questions like “which invoices are over ten dollars?” But a lot of real analysis asks a different kind of question: “how much did we sell in total?”, “what is the average order size?”, or “which state has the most customers?” Answering those means collapsing many rows into a single number — and that is exactly what this module teaches.

Data for this module

Database: chinook.db — a digital music store (SQLite).

Open it in any SQLite client — DB Browser for SQLite, the sqlite3 CLI, or Python’s sqlite3. Each lesson lists the specific tables it uses.

You will start with aggregate functionsCOUNT, SUM, AVG, MIN, and MAX — which take a whole column and return one summary value. From there you will combine aggregates with WHERE, scalar functions, and arithmetic to build richer metrics like average runtime in minutes or rounded sales figures. Then you will meet GROUP BY, the clause that splits your data into groups and computes a summary for each one, so you can compare countries, states, or products side by side. Finally you will group by several columns at once and filter those grouped results with the HAVING clause.

Every example in this module runs against the Chinook database — a realistic dataset for a fictional digital music store, with tables for invoices, tracks, and the individual line items on each sale. You will work with actual columns and see real results, the same way you would on the job.

By the end of the week you will be able to take a raw table and produce the kind of summary tables that decision-makers actually read. Start with Lesson 1, where you meet the five core aggregate functions.

Lessons in this module

Achievement

Complete all 4 lessons to finish the Summarizing Data with SQL module.

Start module