Skip to main content
Here is the basic syntax of the ORDER BY clause:
Syntax

Examples

Let’s assume we have a table named “employees” with columns “employee_id”, “employee_name”, and “salary”.
employees
Code of creating the table and inserting data
To retrieve the list of employees sorted by their salaries in descending order, the SQL query would be:
In this example, the result set displayed the employees’ details sorted by their salaries in descending order, showing the highest-paid employees first. The ORDER BY clause helps in arranging data in a structured and meaningful way for easier interpretation and decision-making.