What is the purpose of the "ORDER BY" clause in SQL?

2025

What is the purpose of the "ORDER BY" clause in SQL?

Answer: B. To sort data in a tableAnswer: To sort data in a table Explanation: The ORDER BY clause sorts the result set based on the values in one or more columns. Default sort order is…

  1. A.

    To filter data in a table

  2. B.

    To sort data in a table

  3. C.

    To combine data from multiple tables

  4. D.

    To aggregate data in a table

Attempted by 1763 students.

Show answer & explanation

Correct answer: B

Answer: To sort data in a table

Explanation: The ORDER BY clause sorts the result set based on the values in one or more columns.

  • Default sort order is ascending. Use DESC to sort in descending order.

  • You can sort by multiple columns; subsequent columns break ties from earlier columns.

  • ORDER BY is applied after filtering (WHERE) and after grouping (GROUP BY) if those are used.

Syntax example: SELECT column_list FROM table_name WHERE conditions ORDER BY column1 DESC, column2 ASC;

Common use: Present query results in a predictable order for reporting, display, or paging.

Explore the full course: Deloitte Nla

Loading lesson…