Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

sql
mysql
avg
communitycreator

What is AVG() in SQL?

harris910

The AVG() function returns the average value of a set of values.

Figure 1 shows a visual representation of the AVG() function.

Figure 1: Visual representation of 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 set of valuescolumn name sent as a parameter.

This function ignores the NULL values 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 averageStudentMarks
from Students

RELATED TAGS

sql
mysql
avg
communitycreator
RELATED COURSES

View all Courses

Keep Exploring