Bird
0
0

In SQL, when combining GROUP BY with ORDER BY, what is the main function of GROUP BY?

easy📝 Conceptual Q1 of 15
SQL - GROUP BY and HAVING
In SQL, when combining GROUP BY with ORDER BY, what is the main function of GROUP BY?
ATo filter rows based on a condition
BTo sort individual rows before grouping them
CTo aggregate rows based on specified columns before sorting the results
DTo join two or more tables
Step-by-Step Solution
Solution:
  1. Step 1: Understand GROUP BY

    The GROUP BY clause groups rows that have the same values in specified columns into summary rows.
  2. Step 2: Role with ORDER BY

    After grouping, ORDER BY sorts these grouped results based on aggregate or grouped columns.
  3. Final Answer:

    To aggregate rows based on specified columns before sorting the results -> Option C
  4. Quick Check:

    Grouping happens before ordering [OK]
Quick Trick: GROUP BY aggregates, ORDER BY sorts grouped results [OK]
Common Mistakes:
MISTAKES
  • Thinking ORDER BY sorts rows before grouping
  • Confusing GROUP BY with filtering
  • Assuming GROUP BY joins tables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes