GROUP BY

SQL GROUP BY and HAVING

GROUP BY is the foundation of aggregated reporting in SQL. It allows you to summarize records by category and then filter the summary results with HAVING.

Common grouped reporting patterns

COUNT

Count rows or distinct values to understand volume.

SUM

Add numeric values up by category or date bucket.

AVG

Measure average values such as basket size or revenue per order.

MIN and MAX

Find the smallest and largest values within grouped data.

HAVING

Filter summary results after aggregation has happened.

Browse examplesSubquery concepts

Ready to learn SQL with real examples?

Learn SQL step by step with practical examples, queries, and interview-focused problem solving.

Get the eBook