ORDER BY keyword is used to order the record in ascending or descending order.
To order the record in in ascending or descending order we use ASC or DESC keywords respectively.
By default ORDER BY keyword short the record in ascending order.
Syntax:
SELECT * FROM table_name
ORDER BY column1,column2, ...ASC|DESC;
Example: To order the students in descending order of there Roll_No:
SELECT * FROM students
ORDER BY Roll_NO DESC;
This will fetch the values as shown below:
Roll_NO | Name | Total_Marks | Phone_Number |
2 | Rahul | 68 | 2147483647 |
1 | Arun | NULL | NULL |