SQL ORDER BY Tutorial

SQL Tutorial: ORDER BY with Example

Learn to use the ORDER BY function in SQL to sort data with our tutorial and screenshots.

ORDER BY

  • The ORDER BY keyword is used to sort data in our table.

  • ORDER BY sorts data based on a specific column(s) in either ascending or descending order.

  • Syntax: SELECT * FROM table ORDER BY column_1 DESC ;

Example

Let’s say we have a basketball league and we keep records of each player, which team they are on, and their basic statistics. 

Stats Table

If we wanted to use a SQL query to find the top rebounders, we would write the following:

SQL ORDER BY

Once we hit enter and run, our result should be as follows:

SQL ORDER BY Result

How to Learn SQL

Master SQL with hands-on training. SQL is one of the most in-demand programming languages and is used across a variety of professions.

Yelp Facebook LinkedIn YouTube Twitter Instagram