How to Sort Table Rows – Here’s Sample SQL Query

The purpose of Ascending or Descending order is to order the SQL results. Do not confuse with Order by clause.

The Order by clause orders or sorts the results based on columns given in the SQL query. On top of ORDER BY the Ascending or Descending sort the rows. Read more on Major vs Minor Sort.

Ascending and Descending order sorting

Short name for Ascending is ASC. The short name for Descending is DESC.

SQL Syntax for DESC and ASC

SELECT language,
FROM proglang_tbl
ORDER BY year DESC, language ASC;


The above result gives ordered results by YEAR. The ASC and DESC role is to sort the results.


  • By default all the results in ORDER BY are Ascending – default is ASC
  • In DESC, the order is highest to lowest value.
  • In Ascending, the order is , lowest to highest value.
  • The ASC and DESC works with ORDER BY clause.


Get new content delivered directly to your inbox.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.