The ORDER BY Operator in SQL
The ORDER BY Operator in SQL
in SQL
Learn how to efficiently sort data in SQL with the ORDER BY operator, a powerful
tool for data analysis and organization.
Introduction to ORDER BY
Operator
1 What is the ORDER BY 2 Why is ORDER BY
Operator? Useful?
3 ORDER BY vs Group By
While GROUP BY groups the result set based on one or more columns,
ORDER BY sorts the result set based on one or more columns.
Syntax and Usage of ORDER BY
John 35 $75,000
Jane 28 $85,000
Bob 42 $90,000
Sara 31 $70,000
For example, this table can be sorted in ascending order based on Age by using the following SQL query:
This will return the same table, but with the rows sorted by Age in ascending order. ORDER BY can also be used to sort
in descending order by using DESC instead of ASC.
Descending Order Sorting
What is Descending Order Sorting? Descending order sorting displays results from the
largest value to the smallest value based on one or
more columns.
How to use Descending Order Sorting To use descending order sorting, simply add DESC
after the column name(s) in the ORDER BY
statement.
1 2 3