ORDER BY Clause

Purpose: The ORDER BY clause sorts the result set based on one or more columns, in ascending or descending order.Syntax:

ORDER BY column1 [ASC|DESC], column2 [ASC|DESC];

Example:

SELECT * FROM employees ORDER BY last_name ASC;

Explanation: This sorts the results alphabetically by last_name. The default is ascending order; use DESC for descending.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *