Database.Beginner.What is the default sort order of ORDER BY?

What is the Default Sort Order of ORDER BY?

By default, ORDER BY sorts in:

Ascending (ASC) order — from smallest to largest, A → Z, 0 → 9.


If you don’t specify anything, this:

SELECT * FROM Employees
ORDER BY salary;

is the same as:

SELECT * FROM Employees
ORDER BY salary ASC;

Default is ASC — Ascending:

  • Numbers: lowest to highest (1, 2, 3, 4...).
  • Text: alphabetical (A, B, C...).
  • Dates: earliest to latest (2023-01-01, 2023-01-02…).

What if you want descending order?

You explicitly specify:

ORDER BY column_name DESC

Numbers: highest to lowest.

Text: Z → A.

Dates: latest to earliest.

Quick Example

namesalary
Alice5000
Bob7000
Carol6000

Default ORDER BY salary:

SELECT * FROM Employees ORDER BY salary;

Result:

namesalary
Alice5000
Carol6000
Bob7000

✅ Sorted ascending — lowest to highest salary.


Explicit ORDER BY salary DESC:

SELECT * FROM Employees ORDER BY salary DESC;

Result:

namesalary
Bob7000
Carol6000
Alice5000

✅ Sorted descending — highest to lowest salary.

In Short

ORDER BY without ASC/DESC sorts in ASC (ascending) order by default.

This entry was posted in Без рубрики. Bookmark the permalink.