core Estimated learning time: 14 h

P-6.3 Joins, Grouping and Aggregates

You can combine tables with inner and outer joins, summarise with grouping, and explain why filtering before and after aggregation are different operations.

Joins are where SQL becomes genuinely powerful and where most people's understanding stops being solid. The mental model that works is that a join produces the combinations that match, and an outer join keeps unmatched rows from one side with the other side missing. Grouping then collapses rows into summaries, and the two filtering steps around it are distinct because one runs on rows and the other on groups.

Work through these

  • An inner join keeps only the rows that match on both sides

    Matching rows from two tables on a shared key gives the combinations that exist in both. Anything unmatched disappears, which is correct here and is the trap in the next item.

    SQLBolt: Learn SQL with interactive exercises · Tutorial
  • Outer joins keep unmatched rows, with the other side missing

    Keeping every row of one table whether or not it matched is how you find customers with no orders. The unmatched columns come back empty, which is the answer rather than a fault.

  • Joining more than two tables, and where it goes wrong

    Each join multiplies the rows that match, so a missing condition produces a result far larger than either input. Checking the row count after every added join catches this immediately.

  • Grouping and the aggregate functions

    Collapsing rows into one per group and counting, summing or averaging within it answers most reporting questions. Every selected column must either be grouped by or aggregated.

  • Filtering rows before grouping against filtering groups after

    One condition decides which rows enter a group and the other decides which finished groups survive. Putting a condition in the wrong place gives an answer that is wrong rather than an error.

    NPTEL: Data Base Management System · Course

Sign in to keep your progress.

Free resources

Links last checked 31 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.