Skip
Arish's avatar

73. AVG Function


AVG Function

AVG calculates the average (mean) value.

Syntax

sql
1SELECT AVG(column) FROM table;

Example: Average Marks

sql
1SELECT AVG(marks) FROM students;

With Rounding

sql
1SELECT ROUND(AVG(marks), 2) AS avg_marks FROM students;

With WHERE

sql
1SELECT AVG(marks) FROM students
2WHERE grade = 'A';