Did you find this useful?
Socialize it today.

SQL AVG Function

Friday, December 09, 2011

tags SQL

The SQL AVG() function returns the average value of a table's column/field.

Employees Table

1000John Smith40
1001Fred White27
1002Jane Scott53
1003Samuel Williams31

In this example, we want to find the average age of an employee.


SELECT AVG(column_name)
FROM Table

SELECT AVG(age) as [Average Age]
FROM employees


SELECT employeeID, employeeName FROM employees
WHERE age > (SELECT AVG(age) from employees)


Average Age

1000John Smith
1002Jane Scott

The SQL AVG function can return the average of a column or can be used with WHERE to filter the rows for the specific range of data that you need.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.

Recommended Books & Training Resources

SQL Cookbook Head First SQL: Your Brain on SQL A Learners Guide