SQL Tutorial

SQL AVG Function

The SQL AVG function calculates the arithmetic average of the series of numbers of its argument. The syntax is simple as follows:

AVG ([DISTINCT]|[ALL] <numeric expression>)

For example, the following queries could be used to caculate the average salary of all employees in employees table:

SELECT AVG(salary) average_salary  
FROM employees

Here is the output:

average_salary
--------------
   2950.000000
Read On