In MySQL, the AVG function calculates the average of a set of numeric values. The syntax is AVG(expression), where expression is the numeric expression to be averaged. It can be used to calculate average price, average score, average quantity, etc.
The meaning of AVG function in MySQL
In MySQL, the AVG function is an aggregate function, used Used to calculate the average of a set of numeric values. It adds a set of numeric values and then divides them by the number of numeric values to get their average.
Grammar
The syntax of the AVG function is as follows:
<code class="sql">AVG(expression)</code>
Among them:
expression
is one or more numeric expressions to be averaged. Usage
The AVG function can be used in a variety of situations, including:
Example
Below Example to calculate the average price of all orders in a sales record:
<code class="sql">SELECT AVG(price) FROM sales_orders;</code>
Result
The AVG function will return the average price of all orders in the table, for example 100.00.
The above is the detailed content of What does avg mean in mysql. For more information, please follow other related articles on the PHP Chinese website!