Introduction
The AVG function helps you find the average value of numbers in a column. It is like finding the middle point of a group of numbers.
Jump into concepts and practice - no test required
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?Employees?Scores with values:ScoreSELECT AVG(Score) FROM Scores; return?SELECT AVG(price) FROM Products WHERE price > 0;Sales with columns Region and Amount. How do you write a query to find the average sales amount per region, excluding regions with no sales?