Database
ORDER BY
Added: June 23, 2026
Definition
ORDER BY is a SQL clause used to sort query results in ascending (ASC) or descending (DESC) order based on one or more columns.
What Problem It Solves
It solves the need to arrange data in a meaningful sequence (e.g., highest salary first, alphabetical names, latest dates).
What Happens If Not Used
Data is returned in unspecified or default database order, which may look random or inconsistent.
Easy Wording
It “arranges data in order.”
Technical Example
A student list is sorted by highest marks first to find top performers easily. SELECT name, marks FROM students ORDER BY marks DESC; Result: students sorted from highest to lowest marks.