Skip
Arish's avatar

84. Sorting with ORDER BY


ORDER BY Clause

ORDER BY sorts results.

Syntax

sql
1SELECT * FROM students
2ORDER BY column;

Example: Sort by Marks

sql
1SELECT * FROM students
2ORDER BY marks;

Sorts from lowest to highest (ascending by default).

Multiple Columns

sql
1SELECT * FROM students
2ORDER BY grade, marks;

First by grade, then by marks within each grade.