Recall & Review
beginner
What does the AVG function do in SQL?
The AVG function calculates the average (mean) value of a numeric column in a table.
Click to reveal answer
beginner
How do you use the AVG function to find the average price from a products table?
Use:
SELECT AVG(price) FROM products; This returns the average of all values in the price column.Click to reveal answer
beginner
Can the AVG function be used with non-numeric columns?
No, AVG only works with numeric columns like integers or decimals. Using it on text columns will cause an error.
Click to reveal answer
intermediate
What happens if the AVG function is used on a column with NULL values?
NULL values are ignored by AVG. It calculates the average only from non-NULL values.
Click to reveal answer
intermediate
How can you find the average salary per department using AVG?
Use GROUP BY:
SELECT department, AVG(salary) FROM employees GROUP BY department; This shows average salary for each department.Click to reveal answer
What does the SQL AVG function return?
✗ Incorrect
AVG calculates the mean (average) of numeric values in a column.
Which SQL query correctly finds the average age from a table named users?
✗ Incorrect
AVG(age) returns the average age; SUM, COUNT, and MAX do different calculations.
How does AVG handle NULL values in a column?
✗ Incorrect
AVG skips NULLs and calculates average only from existing numeric values.
Can AVG be used on a text column?
✗ Incorrect
AVG requires numeric data types; text columns cause errors.
Which SQL clause is used with AVG to get averages per group?
✗ Incorrect
GROUP BY groups rows so AVG can calculate averages for each group.
Explain how the AVG function works and how it treats NULL values.
Think about how you find an average in real life and what happens if some data is missing.
You got /3 concepts.
Describe how to use AVG with GROUP BY to find averages per category.
Imagine you want average scores per class in a school.
You got /3 concepts.