📖
Theory
Understand the concept step by step
ORDER BY is used to sort the result of a query.
By default, sorting is ascending.
You can explicitly use ASC for ascending order or DESC for descending order.
💻
Example
See how the concept works in SQL
SQL
SELECT *
FROM employees
ORDER BY salary DESC;📤
Output
Understand what the query produces
Employees are displayed from highest salary to lowest salary.
📝
Practice
Test your understanding
Sort products by price from highest to lowest.
❓
MCQs
Check your SQL knowledge
What is the main concept covered in ORDER BY?
A.Sorts query results
B.Filters rows
C.Deletes records
D.Creates tables
💼
Interview Questions
Prepare for SQL interviews
1
Interview Question
What does ORDER BY do?
2
Interview Question
What is the difference between ASC and DESC?
3
Interview Question
What is the default sorting order?