The AVG function calculates the arithmetic average of numeric values. It generally ignores NULL values when calculating the average.
Average values help analysts understand typical performance. Analysts can calculate average salary, average order value, average transaction amount, average sales, and many other metrics.
A company wants to know the average salary of its employees. AVG can calculate the average Salary value from the Employees table.
SELECT
AVG(Salary) AS AverageSalary
FROM Employees;
AVG is useful in salary analysis, sales reporting, customer analysis, financial analysis, performance measurement, and operational reporting.
- AVG calculates an arithmetic average.
- AVG is an aggregate function.
- It works with numeric expressions.
- NULL values are generally ignored.
- AVG can be used with GROUP BY.
What does AVG do in SQL?
AVG calculates the arithmetic average of numeric values.
Does AVG normally include NULL values?
No. NULL values are generally ignored when AVG calculates the average.