Database Management · Beginner level

Beginner level · Module 4: Aggregation and Reporting Queries · Lesson 1 of 3

Aggregate Functions

Count, total, average and find the extremes of data with aggregate functions.

In this lesson you will

  • Use COUNT, SUM, AVG, MIN and MAX
  • Explain how aggregates treat NULL

Key concepts

COUNT(*) vs COUNT(column)SUM and AVGMIN and MAXNULL in aggregates

The lesson

Aggregate functions turn many rows into one value: COUNT(*) counts rows, SUM(amount) totals, AVG(amount) averages, and MIN and MAX find the smallest and largest values.

COUNT(*) counts all rows; COUNT(phone) counts only rows where phone is not NULL. AVG ignores NULLs, which can make an average look higher than expected if missing values should really be zero.

Combine aggregates with WHERE: SELECT SUM(amount) FROM payments WHERE paid_on >= '2026-03-01' totals payments since March.

Step by step

  1. Count all students and students with a phone number.
  2. Total and average all payments.
  3. Find the smallest and largest payment.
  4. Total payments for one month with WHERE.

Practice activity

Calculate the school's headline figures: number of students, total collected, average payment and largest payment.

Expected result: All figures match a hand calculation on the sample data.

Check your understanding

  1. What is the difference between COUNT(*) and COUNT(phone)?

    Show answer

    COUNT(*) counts all rows; COUNT(phone) counts rows where phone is not NULL.

  2. Does AVG include NULL values?

    Show answer

    No; it ignores them.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.