< SQL ORDER BY Keyword: Sort Data in Ascending & Descending Order (Step-by-Step Guide) | LearnToSAP

SQL ORDER BY Keyword: Sort Data in Ascending & Descending Order (Step-by-Step Guide)

SQL TUTORIALS-

SQL ORDER BY Key-word

Introduction-


Trulli Trulli

What is SQL ORDER BY? SQL ORDER BY ascending and descending explained

ORDER BY keyword in SQL is used to sort the result set of a query by one or more columns. You can sort the data in ascending (ASC) or descending (DESC) order...


✅ SQL ORDER BY Syntax

✅ 🔹 Syntax:


SELECT column1, column2, ...
FROM table_name
ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...;

Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees


ID Name Salary
1 ANNI 10000
2 SUJAN 8000
3 BOULT 5000

✅ Example:- Sort by Salary (Ascending):-

SELECT Query :-


SELECT * FROM Employees
ORDER BY Salary;

Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees

ID Name Salary
3 BOULT 5000
1 ANNI 10000
2 SUJAN 8000

✅ Example -Sort by Name (Descending):-

SELECT Query :-


SELECT * FROM Employees
ORDER BY Name DESC;

Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees

ID Name Salary
3 BOULT 5000
2 SUJAN 8000
1 ANNI 10000

May Be Like Important Link-

-SQL Tutorial for Beginners – Introduction to SQL

-SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause

-SQL SELECT DISTINCT Statement Clause Explained with Examples

-SQL Wildcard Characters: Complete Guide with Examples