Skip to main content

7. Grouping and Filtering

This module teaches you how to summarize datasets and filter aggregate results without breaking query correctness.

Decision Guide

GoalClause to useWhy
Group rows by one or more keysGROUP BYProduces aggregate result sets
Filter rows before groupingWHEREReduces input rows early
Filter grouped resultsHAVINGApplies conditions after aggregation
Produce subtotals/grand totalsROLLUP / GROUPING SETSReporting-friendly totals

Lessons

What's Next