Introduction
The AVG function helps you find the average value of numbers in a column. It makes it easy to see the typical or middle value in a group of numbers.
SELECT AVG(column_name) FROM table_name;
SELECT AVG(price) FROM products;
SELECT AVG(score) FROM exams WHERE subject = 'Math';
SELECT AVG(salary) FROM employees WHERE department = 'Sales';
CREATE TABLE sales ( id INT, amount DECIMAL(10,2) ); INSERT INTO sales (id, amount) VALUES (1, 100.00), (2, 150.00), (3, 200.00), (4, NULL); SELECT AVG(amount) AS average_amount FROM sales;
AVG() function do in MySQL?AVG() function is designed to calculate the average (mean) of numeric values in a column.COUNT(), MAX(), or SUM(), AVG() specifically returns the average value.employees?AVG() as a function with the column name inside parentheses.AVG(salary) correctly. Options A, C, and D have syntax errors or wrong function names.scores with values:id | score
1 | 80
2 | 90
3 | NULL
4 | 70SELECT AVG(score) FROM scores; return?SELECT AVG(price) FROM products WHERE price > 0;sales table with columns region and amount. How do you write a query to find the average sales amount per region, excluding regions with no sales?GROUP BY region to calculate averages per region.HAVING AVG(amount) > 0 to exclude groups where average is NULL or 0 (no sales).SELECT region, AVG(amount) FROM sales WHERE amount IS NOT NULL GROUP BY region;) filters NULL rows before grouping but includes regions where non-NULL amounts average to 0. Options C and D have syntax errors or misuse WHERE with GROUP BY.Pass the test and this pattern moves unknown