Bird
0
0

Why must the ORDER BY clause appear only once after all set operations like UNION or INTERSECT in a SQL query?

hard📝 Conceptual Q10 of 15
SQL - Set Operations
Why must the ORDER BY clause appear only once after all set operations like UNION or INTERSECT in a SQL query?
ABecause ORDER BY is not allowed in any SELECT statement
BBecause ORDER BY sorts the final combined result set, not individual queries
CBecause ORDER BY can only sort numeric columns
DBecause ORDER BY must be inside each SELECT before UNION
Step-by-Step Solution
Solution:
  1. Step 1: Understand set operation behavior

    Set operations combine multiple query results into one final set.

  2. Step 2: Role of ORDER BY

    ORDER BY sorts the entire combined result, so it must appear once at the end.

  3. Final Answer:

    ORDER BY sorts the final combined result set, not individual queries -> Option B
  4. Quick Check:

    ORDER BY after set operations sorts combined output [OK]
Quick Trick: ORDER BY sorts combined results; place it once at the end [OK]
Common Mistakes:
MISTAKES
  • Placing ORDER BY inside each SELECT with UNION
  • Thinking ORDER BY is disallowed
  • Assuming ORDER BY only sorts numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes