Recall & Review
beginner
What does the GROUP BY clause do in a SQL query?
It groups rows that have the same values in specified columns into summary rows, like grouping all sales by each product.
Click to reveal answer
beginner
How does GROUP BY affect the output of a query?
It changes the output from listing individual rows to showing one row per group, summarizing data for each group.
Click to reveal answer
beginner
Why do we often use aggregate functions with GROUP BY?
Because GROUP BY groups rows, aggregate functions like SUM or COUNT calculate a single value for each group.
Click to reveal answer
intermediate
What happens if you select columns not in GROUP BY or aggregate functions?
The query will usually give an error because SQL doesn't know how to group or summarize those columns.
Click to reveal answer
intermediate
How does GROUP BY change the way SQL processes data internally?
SQL first filters rows (WHERE clause), then groups rows by the specified columns, then applies aggregate functions to each group before returning results.
Click to reveal answer
What is the main purpose of the GROUP BY clause in SQL?
✗ Incorrect
GROUP BY groups rows that share the same values in specified columns into summary rows.
Which of the following is commonly used with GROUP BY to summarize data?
✗ Incorrect
Aggregate functions calculate summary values for each group created by GROUP BY.
What happens if you select a column not in GROUP BY or an aggregate function?
✗ Incorrect
SQL requires all selected columns to be either grouped or aggregated; otherwise, it throws an error.
How does GROUP BY affect the number of rows returned?
✗ Incorrect
GROUP BY combines rows with the same values, so fewer rows are returned as groups.
When does SQL apply the GROUP BY operation during query execution?
✗ Incorrect
SQL filters rows first (WHERE), then groups them (GROUP BY), then selects columns and aggregates.
Explain how the GROUP BY clause changes the way SQL returns data compared to a simple SELECT.
Think about how data is summarized instead of shown row by row.
You got /4 concepts.
Describe what happens internally in SQL when a query includes a GROUP BY clause.
Focus on the order of operations inside SQL.
You got /4 concepts.