SQL ORDER BY keyword – SQL TUTORIAL | Software Testing Material
SQL ORDER BY keyword:
SQL ORDER BY keyword is used to sort the data in ascending or descending order, based on one or more columns.
Syntax:
SELECT column_name_1, column_name_2 FROM table_name ORDER BY column_name_1 ASC|DESC, column_name_2 ASC|DESC;
Example:
Order By – Ascending Order:
SELECT * FROM SCOREBOARD ORDER BY Playername ASC;
In the below image, you could find two SELECT statements. Second SELECT statement displays the records in Ascending order with respect to ‘Playername‘
Order By – Descending Order:
SELECT * FROM SCOREBOARD ORDER BY Playername DESC;
In the below image, you could find two SELECT statements. Second SELECT statement displays the records in Descending order with respect to ‘Playername‘.
In the next tutorial, we will see How To Use GROUP BY in SQL
Check out the complete SQL Tutorial by clicking on below link: