Bird
0
0

What advantage does using a CASE expression in an ORDER BY clause provide when sorting query results?

easy📝 Conceptual Q1 of 15
SQL - CASE Expressions
What advantage does using a CASE expression in an ORDER BY clause provide when sorting query results?
AIt automatically groups rows with the same values
BIt allows custom sorting logic based on conditions within rows
CIt speeds up the query execution by indexing
DIt filters rows before sorting
Step-by-Step Solution
Solution:
  1. Step 1: Understand ORDER BY

    The ORDER BY clause sorts query results based on column values.
  2. Step 2: Role of CASE

    Using CASE inside ORDER BY lets you define custom sorting priorities by evaluating conditions per row.
  3. Final Answer:

    It allows custom sorting logic based on conditions within rows -> Option B
  4. Quick Check:

    CASE customizes sort order [OK]
Quick Trick: CASE customizes sorting order dynamically [OK]
Common Mistakes:
  • Thinking CASE filters rows instead of sorting
  • Assuming CASE speeds up query execution
  • Confusing grouping with sorting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes