PostgreSQL for Developers
LESSON 1.2

Aggregates and GROUP BY

Learn key techniques and workflows in PostgreSQL for Developers.

6m
intermediate
11,276 students

Overview

Aggregation collapses rows into summaries. WHERE filters before grouping and HAVING after — mixing them up is the classic bug.

In this lesson you will:

  • Aggregate with count, sum, avg, min, and max
  • Group correctly and know what must be in GROUP BY
  • Filter groups with HAVING, rows with WHERE

Pro Tip

Use caching and revalidation wisely to ensure your app stays fast and data remains fresh without unnecessary requests.

Resources