×
×
SQL Tutorial
What is SQL SQL SELECT SQL SELECT DISTINCT SQL WHERE SQL INSERT SQL UPDATE SQL DELETE SQL AND, OR & NOT Clause SQL ORDER BY SQL LIKE Clause SQL IN Operator SQL BETWEEN Operator SQL MAX() and MIN() SQL COUNTSQL JOIN
SQL JOIN SQL INNER JOIN SQL LEFT JOIN SQL RIGHT JOIN SQL FULL OUTER JOINSQL ORDER BY
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
Syntax:
SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1] [ASC | DESC];
Example Database:
This is customers table.
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
2 | Amit | Haryana |
3 | Siddarth | Noida |
4 | Vikas | Noida |
ORDER BY DESC
Example: The following code block has an example, which would sort the result in the descending order by NAME.
Syntax:
SELECT * FROM customers ORDER BY name DESC;
Result:
id | name | Location |
---|---|---|
4 | Vikas | Noida |
3 | Siddarth | Noida |
1 | Kailash | Delhi |
2 | Amit | Haryana |
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date
Copyright 2018 - 2025 Elevenstech Web Tutorials All rights reserved.