C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
MySQL AVG() FunctionThe avg() is a Math function of MySQL. This function is used to get the average value from the given expression. Syntaxselect avg(aggregate_expression) from table_name [where condition]; Parameteraggregate_expression: It is the column name for getting average table_name: It is the table for getting records. where condition: It is optional. It is used to get conditional records. ReturnsThis function returns the average value from the given expression.
Table:![]() Example 1select avg(marks) as "Total Marks" from table2; Output: ![]() Example 2select avg(marks) as "Total Marks" from table2 where marks>65; Output: ![]() Example 3select avg(DISTINCT marks) as "Total Marks" from table2 where marks>60; Output: ![]()
Next TopicMySQL Math
|