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 salary from an Employees table?
Use: <br>
SELECT AVG(salary) FROM Employees;<br>This returns the average salary of all employees.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 or dates 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 the non-NULL values.
Click to reveal answer
intermediate
How can you find the average salary per department using AVG?
Use GROUP BY with AVG:<br>
SELECT department, AVG(salary) FROM Employees GROUP BY department;<br>This shows average salary for each department.Click to reveal answer
What does the SQL AVG function calculate?
✗ Incorrect
AVG calculates the average (mean) of numeric values in a column.
Which SQL query correctly finds the average price from a Products table?
✗ Incorrect
AVG(price) returns the average price; SUM, COUNT, MAX do different calculations.
How does AVG handle NULL values in a column?
✗ Incorrect
AVG skips NULLs and calculates average from existing numeric values.
Can AVG be used on a text column?
✗ Incorrect
AVG requires numeric data; text columns cause errors.
How do you find the average salary per department?
✗ Incorrect
GROUP BY groups rows by department, AVG calculates average salary per group.
Explain how the AVG function works in SQL and how it treats NULL values.
Think about how average is calculated in math and what happens if some values are missing.
You got /3 concepts.
Describe how to use the AVG function with GROUP BY to find averages per category.
Grouping data helps calculate averages for each group separately.
You got /3 concepts.