Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
SQL does not guarantee row order unless ORDER BY is specified. This question verifies that ORDER BY is the standard mechanism to sort SELECT output in ascending or descending order by one or more expressions.
Given Data / Assumptions:
Concept / Approach:
ORDER BY appends to SELECT to sort rows by column(s) or expressions. Without it, the DBMS may return rows in any order that satisfies the query plan. ORDER BY is independent of indexes, GROUP BY, or data types; it is a logical directive that the optimizer will implement, possibly via sorting or index scans.
Step-by-Step Solution:
Verification / Alternative check:
Compare results with and without ORDER BY; only the ORDER BY version ensures deterministic order, which is critical for pagination and consistent reporting.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming “natural” order equals insertion order—this is unreliable. Always use ORDER BY for predictable presentation.
Final Answer:
Correct
Discussion & Comments