Recall & Review
beginner
What does the term aggregate function mean in SQL?
An aggregate function performs a calculation on a set of values and returns a single value, like SUM, COUNT, AVG, MIN, or MAX.
Click to reveal answer
beginner
How can you combine multiple aggregate functions in one SQL query?
You can list multiple aggregate functions separated by commas in the SELECT clause, for example: SELECT COUNT(*), AVG(price) FROM products;
Click to reveal answer
intermediate
Why do we use
GROUP BY with aggregate functions?GROUP BY groups rows that have the same values in specified columns so aggregate functions can calculate results for each group separately.
Click to reveal answer
intermediate
What will this query return? <br>
SELECT department, COUNT(*), AVG(salary) FROM employees GROUP BY department;It returns each department's name, the number of employees in that department, and the average salary of employees in that department.
Click to reveal answer
intermediate
Can you combine aggregate functions without GROUP BY? What happens?
Yes, you can combine aggregates without GROUP BY. The functions will calculate over the entire table and return one row with combined results.
Click to reveal answer
Which SQL clause is used to group rows for aggregate calculations?
✗ Incorrect
GROUP BY groups rows so aggregate functions can calculate results per group.
What does this query return? <br>
SELECT COUNT(*), SUM(quantity) FROM sales;✗ Incorrect
COUNT(*) counts rows, SUM(quantity) adds all quantity values.
Can you use multiple aggregate functions in one SELECT statement?
✗ Incorrect
You can list multiple aggregates separated by commas in SELECT.
What happens if you use aggregate functions without GROUP BY?
✗ Incorrect
Without GROUP BY, aggregates summarize the entire table.
Which of these is NOT an aggregate function?
✗ Incorrect
SELECT is a SQL command, not an aggregate function.
Explain how to combine multiple aggregate functions in a single SQL query and when to use GROUP BY.
Think about how to get counts and averages per category.
You got /4 concepts.
Describe what happens when you use aggregate functions without a GROUP BY clause.
Consider the whole table as one group.
You got /3 concepts.