In MySQL, the AVG function is used to get the average value of an expression.
SELECT AVG (aggregate_expression) FROM table_name WHERE conditions;
Aggregate_expression: It is used to specify the column or expression to be utilised by the AVG function.
ID NAME QUANTITY 1 Electronics 30 2 Sports 45 3 Fashion 100 4 Electronics 90 5 Sports 50
SELECT AVG(quantity) AS “Average Quantity” FROM items;
AVERAGE QUANTITY 63 1 row in set <0.00 sec>
The ‘items’ is an already existing table from which we are calculating the average value of ‘quantity’.