ORDER BY

SQL ORDER BY Keyword

The ORDER BY clause is used to sort the results of a query in ascending (default) or descending order.

Tutorials dojo strip

SQL ORDER BY Syntax

SQL

SQL ORDER BY Default (Ascending) Example

This query selects all patients and sorts them by last_name in ascending order.

SQL

SQL ORDER BY ASC Example

This query selects all doctors and sorts them by specialty in ascending (A–Z) order.

SQL

SQL ORDER BY DESC Example

This query selects all appointments and sorts them by appointment_date in descending (latest first) order.

SQL

SQL ORDER BY Labs

Tutorials dojo strip