TheAnalyst / SQLAll lessons ↗
Day 9 · Aggregation & joins · 10–20 minutes

COUNT and basic aggregation

COUNT, SUM, AVG, MIN and MAX summarize rows.

01 · Learn

The idea

COUNT, SUM, AVG, MIN and MAX summarize rows. Read the query line by line and identify the input table, the transformation, and the shape of the result before running it.

SELECT COUNT(*) AS order_count, SUM(amount) AS revenue FROM orders;
Read it actively

Before running the example, predict the output columns and whether the query returns one row, many rows, or possibly no rows.

02 · Recall

Explain it without looking

In your own words, explain the main SQL feature in today’s lesson and why it answers the question.

03 · Solve

Run your own query

Return the number of orders and the total order value.

Loading browser SQL engine…
04 · Repeat

Close the loop