thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Foundational

ORDER BY Clause

The clause that sorts the final result set by one or more expressions, ascending (default) or descending.

Definition

Without ORDER BY, relational results have no guaranteed order, even if they appear sorted. ORDER BY can reference column aliases and ordinal positions. Where NULLs sort is vendor-specific, and NULLS FIRST or NULLS LAST overrides it.

Example

ORDER BY LastName ASC, HireDate DESC

Exam tip

Never rely on insertion or index order; only ORDER BY guarantees the sort.

Related terms