RANIARANIA Academy

Aggregation & Grouping

Turn raw rows into the summaries a report needs — counts, totals, averages and per-category breakdowns — using PostgreSQL's aggregate functions, GROUP BY and HAVING. You will finish able to summarise data for reporting, filter groups correctly, count distinct values and produce subtotals with ROLLUP.

Watch the free preview

Counting rows with COUNT — free to watch, no account needed.

PostgreSQL INTERMEDIATE · 150 min · Certificate on completion · 3 CPD points

What you'll learn

  • Summarise data for reporting with COUNT, SUM, AVG, MIN and MAX
  • Group rows by one or more columns with GROUP BY
  • Filter groups correctly using HAVING rather than WHERE
  • Count distinct values and combine joins with aggregation
  • Produce subtotals and grand totals with GROUPING SETS and ROLLUP

Syllabus

Aggregate Functions — the Basics
Counting rows with COUNTFree preview15 min
Totals and averages with SUM, AVG, MIN and MAX15 min
Grouping Rows with GROUP BY
GROUP BY — one summary per category15 min
Multi-column grouping and aggregating across joins15 min
Filtering Groups and Counting Distinct
HAVING versus WHERE15 min
DISTINCT and counting unique values15 min
Advanced Aggregation for Reporting
Subtotals with GROUPING SETS, ROLLUP and CUBE15 min
FILTER, conditional aggregates and building a report15 min
Lab — 10 Exercises & Solutions
Exercises 1–515 min
Exercises 6–1015 min