Skip to main content
SQL • LESSON 04

ORDER BY

How can we sort query results in ascending or descending order?

Beginner2 Minutes150 XP
🤔 THE QUESTION

How can we sort query results in ascending or descending order?

💡 WHAT IS IT?

ORDER BY sorts the returned rows by one or more specified columns in ASC or DESC direction.

🎯 WHAT IS IT USED FOR?

Creating leaderboards, sorting by latest dates, organizing records by numeric value.

💻 EXAMPLE
SELECT *
FROM employees
ORDER BY salary DESC;

🎯 Mission Objectives

Practice typing production-grade SQL code for ORDER BY.

  • ORDER BY
  • DESC / ASC
  • Sorting
  • Column ordering