Summarizing data: Aggregate functions and grouping

Beginner
Database Administrator
Developer
Azure Database for PostgreSQL

This module introduces aggregate functions in SQL, which are essential for analyzing data. You learn how to use functions like COUNT, SUM, AVG, MIN and MAX, group data using the GROUP BY clause and filter grouped results with the HAVING clause.

Learning objectives

By the end of this module, you'll be able to:

  • Understand the role of aggregate functions in data analysis
  • Use COUNT to count all rows or distinct values in a column
  • Use SUM to calculate the total of values in a numeric column
  • Use AVG to compute the average of numeric values in a column
  • Use MIN and MAX to find the lowest and highest values in a column
  • Group data using GROUP BY to apply aggregate functions to each group
  • Differentiate between GROUP BY and DISTINCT, and use GROUP BY even without aggregate functions to list unique values
  • Use HAVING to filter grouped results based on aggregate function outcomes

Prerequisites

Before starting this module, you should have a basic understanding of SQL SELECT statement.