Skip to main content
Order results using the ORDER BY clause.

Basic Syntax

Ascending Order (Default)

Descending Order

Multiple Columns

Expressions in ORDER BY

Sort by calculated values or function results.

Function in ORDER BY

With WHERE Clause

With LIMIT

Pagination Pattern

Complete Example

Next Steps

Joins

Combine multiple tables

Grouping

Aggregate with GROUP BY