AVG calculates the arithmetic mean of numeric values from rows selected by the query. After a JOIN, it can calculate averages for each related group.
Average transaction value, salary, order amount, and processing time are common analytical measures.
Calculate the average order value for each customer.
SELECT
c.CustomerName,
AVG(o.OrderAmount) AS AverageOrderValue
FROM Customers c
INNER JOIN Orders o
ON c.CustomerID = o.CustomerID
GROUP BY
c.CustomerName;
Used in customer analytics, sales performance, financial analysis, and operational reporting.
- AVG calculates the arithmetic mean.
- NULL values are generally ignored by AVG.
- JOIN determines the related records included.
- GROUP BY calculates averages per entity.
- Check whether the JOIN level matches the business requirement.
How can AVG be used with JOIN?
AVG can calculate the average value of related rows after the tables are joined and grouped.
Does AVG include NULL values?
In standard SQL, AVG ignores NULL values when calculating the average.