SQL ORDER BY keyword

0
135

sqltuts

ORDER BY used to define how the records are to be sorted. By default, it is to order in ascending order(ASC).

If we want to sort in descending order, we can use DESC after the column name.

Syntax:

For example, consider the following table Employee:

Employee_id First_name Last_name sex
123 Mack Johnson male
124 Jack Obama male
125 King Khan male

 

This would give the following output:

Employee_id First_name Last_name sex
125 King Khan male
124 Jack Obama male
123 Mack Johnson male

 

Example:

Sorting in descending order by using “ORDER BY clause”

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.