ORDER BY

The ORDER BY clause is used to sort data in a table.

It arranges rows in ascending (default) or descending order.

Syntax

SELECT column1, column2 FROM table_name ORDER BY column1 ASC;

OR

SELECT column1, column2 FROM table_name ORDER BY column1 DESC;

Example

  • Sort students by GPA in descending order (highest first):
SELECT Name, GPA FROM Students ORDER BY GPA DESC;

Question number:

Up Next: Practice LIMIT and OFFSET

Donate

About

Privacy Policy

Changelog