Skip
Arish's avatar

94. ORDER BY with DISTINCT


Sorting Unique Values

Combine DISTINCT with ORDER BY.

sql
1SELECT DISTINCT course FROM students
2ORDER BY course;

Returns unique courses in alphabetical order.

Descending

sql
1SELECT DISTINCT marks FROM students
2ORDER BY marks DESC;