What is AVG() in SQL?
The AVG() function returns the average value of a set of values.
Figure 1 shows a visual representation of the AVG() function.
Syntax
AVG(column)
Parameter
The AVG() function takes a column or field as a parameter.
Return value
The AVG() function returns the average value of a
This function ignores the
NULLvalues in the column or field.
Code
The following example shows how we can get the average of the student marks using the AVG() function.
Students
Student ID | Student Name | Student Marks |
1 | David | 22 |
2 | Luiss | 20 |
3 | Harvey | 15 |
4 | Lucy | 25 |
5 | Andrew | 10 |
select AVG(studentMarks) as averageStudentMarksfrom Students