Beginner

544. JOIN with AVG

Use AVG with JOINs to calculate average values across related records.

📘 Lesson 544 of 728 ⏱ 12 min 🎯 Intermediate

AVG calculates the arithmetic average of numeric values. When combined with JOINs, it can calculate averages for groups of related records.

Average order value, average salary, average transaction amount, and similar metrics are common business measures.

Calculate the average order amount for each customer.

SQL
SELECT
    c.CustomerName,
    AVG(o.OrderAmount) AS AverageOrderAmount
FROM Customers c
INNER JOIN Orders o
    ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerName;

Used in customer analytics, financial analysis, sales reporting, and performance measurement.

  • AVG calculates the arithmetic mean.
  • JOIN determines the related records.
  • GROUP BY calculates averages by category.
  • NULL values are not included by AVG.
  • Duplicate rows can affect the average.
How is AVG used with JOIN?

AVG can calculate the average of a numeric column across records related through a JOIN.

Does AVG include NULL values?

No. AVG ignores NULL values in the expression being averaged.

Have you finished this lesson?

Introduction to SQL – All Lessons