Which SQL clause is used to sort rows in a query result?
2026
Which SQL clause is used to sort rows in a query result?
Answer: B. ORDER BY — ConceptA query clause controls a specific stage of result construction. Sorting arranges returned rows by one or more expressions, while grouping combines…
- A.
SORT BY - B.
ORDER BY - C.
GROUP BY - D.
FILTER BY
Attempted by 232 students.
Show answer & explanation
Correct answer: B
Concept
A query clause controls a specific stage of result construction. Sorting arranges returned rows by one or more expressions, while grouping combines rows for aggregation and filtering chooses rows.
ASC and DESC specify the direction when a sorting clause permits them.
Application
The requested operation is to arrange the rows returned by a query.
SQL expresses this operation with
ORDER BY, followed by a column or expression.For example,
SELECT name FROM student ORDER BY name ASC;arranges the returned names in ascending order.
Cross-check and contrast
SORT BYis wording used by some non-SQL tools, not a standardSELECTclause.ORDER BYorders result rows and can useASCorDESC.GROUP BYforms groups for aggregate calculations.FILTER BYis wording used by some tools; SQL row filtering usesWHEREorHAVING.
Result
Therefore, the clause used to sort query results is ORDER BY.