Bird
0
0

Why does SQL require all non-aggregated columns in the SELECT clause to be included in the GROUP BY clause?

hard📝 Conceptual Q10 of 15
SQL - GROUP BY and HAVING
Why does SQL require all non-aggregated columns in the SELECT clause to be included in the GROUP BY clause?
ATo ensure each output row represents a unique group
BTo speed up query execution
CTo allow duplicate rows in the result
DTo avoid using aggregate functions
Step-by-Step Solution
Solution:
  1. Step 1: Understand grouping rules

    Non-aggregated columns must be grouped to define unique groups for output rows.
  2. Step 2: Reason about output uniqueness

    This ensures each row in the result corresponds to one unique group, avoiding ambiguity.
  3. Final Answer:

    To ensure each output row represents a unique group -> Option A
  4. Quick Check:

    Non-aggregated columns must be grouped = A [OK]
Quick Trick: Non-aggregated columns must be grouped for unique rows [OK]
Common Mistakes:
MISTAKES
  • Thinking grouping is for performance only
  • Believing duplicates are allowed in grouped output
  • Assuming aggregate functions are optional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes