The SQL AVG function returns the average value within a table or group. In this section, we’ll use the HumanResource.Employee table for our examples:

SQL AVG Function

Using sample data above, AVG calculates the average SickLeaveHours amount for the entire table:

SELECT AVG(sickleavehours) AVGSickLeaveHours FROM HumanResources.Employee
SELECT AVG(sickleavehours) AVGSickLeaveHours 
  FROM HumanResources.Employee

When used with GROUP BY, AVG returns the average value within a group. You can see this in this query showing the maximum SickLeaveHours by JobTitle: 

SELECT JobTitle , AVG(sickleavehours) AS AVGSickLeaveHours FROM HumanResources.Employee GROUP BY JobTitle ORDER BY JobTitle;
SELECT JobTitle 
 , AVG(sickleavehours) AS AVGSickLeaveHours 
FROM HumanResources.Employee 
GROUP BY JobTitle 
ORDER BY JobTitle; 

Additional SQL AVG Resources  

To learn more, check out these useful resources: 

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Are YOU READY TO START LEARNING SQL SERVER, BUT DON'T KNOW WHERE TO START?

Nothing is worse than, being excited to learn a new tool but not knowing where to start, wasting time learning the wrong features, and being overwhelmed .

But it doesn't have to be this way.

I'm Putting together a free email course to help you get started learning SQL Server.

Name*
Email*
>