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 BYConceptA query clause controls a specific stage of result construction. Sorting arranges returned rows by one or more expressions, while grouping combines…

  1. A.

    SORT BY

  2. B.

    ORDER BY

  3. C.

    GROUP BY

  4. 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

  1. The requested operation is to arrange the rows returned by a query.

  2. SQL expresses this operation with ORDER BY, followed by a column or expression.

  3. For example, SELECT name FROM student ORDER BY name ASC; arranges the returned names in ascending order.

Cross-check and contrast

  • SORT BY is wording used by some non-SQL tools, not a standard SELECT clause.

  • ORDER BY orders result rows and can use ASC or DESC.

  • GROUP BY forms groups for aggregate calculations.

  • FILTER BY is wording used by some tools; SQL row filtering uses WHERE or HAVING.

Result

Therefore, the clause used to sort query results is ORDER BY.

Explore the full course: Niacl Ao It Specialist

Loading lesson…