The SQL AVG aggregate function is used to calculate the average values of the column.
The SQL AVG syntax is simple and looks like this:
SELECT AVG ( [COLUMN NAME] ) FROM [TABLE NAME]
EXAMPLE :
Let's try it out with a simple example which is return average of the scores in the table.
Table GameScores
PlayerName | Department | Scores |
Jason | IT | 3000 |
Irene | IT | 1500 |
Jane | Marketing | 1000 |
David | Marketing | 2500 |
Paul | HR | 2000 |
James | HR | 2000 |
SQL statement :
SELECT AVG(Scores) FROM GameScores
Result:
AVG(Scores) |
2000 |