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 table — 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…
- A.
To filter data in a table
- B.
To sort data in a table
- C.
To combine data from multiple tables
- 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.