Use of SQL ORDER BY keyword for sorting by ascending and descending order

Author: Al-mamun Sarkar Date: 2020-04-14 18:01:58

Use of SQL ORDER BY Keyword for Arranging By Ascending and Descending Order. The following code show how to use ORDER BY for sorting data by ascending and descending order. 

 

SQL Order By Syntax:

SELECT column, column
FROM table_name
ORDER BY column, column ASC|DESC;

Example:

SELECT * FROM employees
ORDER BY country;

 

Sorting on descending order:

SELECT * FROM employees
ORDER BY country DESC;

 

ORDER BY Several Columns Example:

SELECT * FROM employees
ORDER BY country, name;

 

SELECT * FROM employees
ORDER BY country ASC, name DESC;