devxlogo

Understanding the AVG Function in MySQL

Understanding the AVG Function in MySQL

Assume there is a column named MARKS in the table STUDENT_DETAILS, and we need to calculate the average. The following query will be necessary:

SELECT AVG(MARKS) AVERAGE FROM STUDENT_DETAILS; 

This will calculate and display the average of the available values in the MARKS column as below.

Assuming the values as 5,6 and 7 in three rows, it works as below.

+ -- -- -- -- -- -+| AVERAGE |+ -- -- -- -- -- -+| 6.0000 |+ -- -- -- -- -- -+
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist