Bird
0
0

Why must all non-aggregated columns in the SELECT clause appear in the GROUP BY clause when using aggregate functions?

hard📝 Conceptual Q10 of 15
SQL - GROUP BY and HAVING
Why must all non-aggregated columns in the SELECT clause appear in the GROUP BY clause when using aggregate functions?
ATo avoid syntax errors caused by missing WHERE clauses
BBecause SQL requires all columns to be aggregated
CTo ensure each row in the result is uniquely identified by the grouped columns
DTo speed up query execution
Step-by-Step Solution
Solution:
  1. Step 1: Understand grouping logic

    GROUP BY groups rows so each group is identified by the grouped columns.
  2. Step 2: Explain non-aggregated columns role

    Non-aggregated columns must appear in GROUP BY to avoid ambiguity about which row's value to show.
  3. Final Answer:

    To ensure each row in the result is uniquely identified by the grouped columns -> Option C
  4. Quick Check:

    Non-aggregated columns must be grouped for unique results [OK]
Quick Trick: Non-aggregated SELECT columns must be in GROUP BY [OK]
Common Mistakes:
MISTAKES
  • Thinking all columns must be aggregated
  • Confusing WHERE clause errors with GROUP BY rules
  • Assuming it improves speed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes