MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL avg() Function

The MySQL sum() function returns the average of a numeric field. It is used when you need to find or calculate average of numeric fields value.

MySQL AVG FUNCTION Syntax

To find or calculate average of numeric field in a table, use the following syntax:

Syntax

SELECT AVG(col1) 
FROM tablename
WHERE condition;

Parameters:

tablename: The table name from which you want to fetch records.

col1: The column or field name that will used to calculate average.

condition: To specifies the conditions that must be fulfilled. It is optional.

MySQL AVG FUNCTION example

The following MySQL, calculating average of the numeric field "workingHours" in the "tblCustomerLoan" table:

Example

SELECT AVG(workingHours) AS TotalAverage FROM tblCustomerLoan;

Note:

In the above example, we are calculating average of "workingHours" numeric field value in tblCustomerLoan" table.

You can use MySQL Command Line Client to find or calculate average of numeric fields value in the specified table. It will look like this: