Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
GROUP BY is essential for reporting and analytics—summing sales per region, counting orders per customer, and so on. This item asks whether GROUP BY collects rows sharing equal values into groups for aggregation.
Given Data / Assumptions:
Concept / Approach:
GROUP BY partitions the result set by the specified key(s). Each partition receives aggregate calculations. For example: SELECT region, SUM(amount) FROM sales GROUP BY region; computes totals per region. With multiple keys: GROUP BY region, year creates groups for each unique combination of region and year.
Step-by-Step Solution:
Verification / Alternative check:
Compare row counts before and after grouping; unique combinations of GROUP BY keys should equal the number of groups returned.
Why Other Options Are Wrong:
Common Pitfalls:
Selecting non-aggregated columns not listed in GROUP BY (violates standard SQL), and confusing HAVING (post-group filter) with WHERE (pre-group filter).
Final Answer:
Correct
Discussion & Comments