Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
sql order by clause with descending order

SQL ORDER BY Clause with Descending Order

Posted on February 10, 2025February 10, 2025 By Rishabh saini No Comments on SQL ORDER BY Clause with Descending Order

SQL ORDER BY Clause with Descending Order

Whenever we want to sort records based on specific columns in an SQL database, we use the ORDER BY clause. This clause allows us to organize data in either ascending or descending order, making it easier to analyze and retrieve information efficiently.

Complete Python Course with Advance topics:-Click Here
SQL Tutorial :-Click Here

Understanding the ORDER BY Clause

The ORDER BY clause sorts the values in a particular column and then displays the entire dataset based on that sorted order. By default, SQL sorts data in ascending order if no sorting keyword is specified. However, if we need the data in descending order, we use the DESC keyword.

Syntax for Sorting in Descending Order:

SELECT ColumnName1, ColumnName2, ... FROM TableName ORDER BY ColumnName DESC;

Let’s explore the ORDER BY clause using MySQL examples.

Example 1: Sorting Customers by Name in Descending Order

Consider a customers table with the following records:

IDNAMEAGECITYINCOME
1Aman Verma30Delhi50000
2Rahul Sharma28Mumbai45000
3Kiran Mehta35Pune52000
4Neha Kapoor40Kolkata60000
5Pooja Singh32Chennai48000
6Rohit Malhotra25Jaipur41000
7Arjun Khanna27Hyderabad47000
8Sneha Choudhary29Ahmedabad49000
9Varun Joshi31Bangalore53000
10Meera Nair34Chandigarh51000

Query:

SELECT * FROM customers ORDER BY Name DESC;

Output:

The records are displayed in descending order of the Name column.

Example 2: Sorting Customers by City in Descending Order

Query:

SELECT * FROM customers ORDER BY City DESC;

Output:

Records are arranged in descending order of the City column.

Example 3: Sorting Customers by Income in Descending Order

Query:

SELECT * FROM customers ORDER BY Income DESC;

Output:

Records are arranged in descending order of the Income column.

Example 4: Sorting Customers by Age in Descending Order

Query:

SELECT * FROM customers ORDER BY Age DESC;

Output:

Records are arranged in descending order of the Age column.

Example 5: Sorting Agents by Name in Descending Order

Consider another table agents with the following records:

AIDNAMEREGIONCOMMISSIONPHONESALARY
1Vikram SethiBangalore1%987654321045000
2Priya NandaChennai5%876543210935000
3Aman KapoorMumbai2%765432109860000
4Rhea DesaiPune3%654321098737500
5Nitin JoshiDelhi4%543210987640000
6Anjali SaxenaJaipur8%432109876527000
7Dev SharmaChandigarh6%321098765432000
8Kunal BatraUdaipur2%210987654326000
9Sneha PillaiUjjain9%109876543239000
10Akash VermaGoa7%019876543246000

Query:

SELECT * FROM agents ORDER BY Name DESC;

Output:

Records are displayed in descending order of the Name column.

Example 6: Sorting Agents by Salary in Descending Order

Query:

SELECT * FROM agents ORDER BY Salary DESC;

Output:

Records are displayed in descending order of the Salary column.

Download New Real Time Projects :-Click here
Complete Advance AI topics:- CLICK HERE

Conclusion

The ORDER BY clause is a crucial tool in SQL that helps organize records efficiently. By using the DESC keyword, we can easily sort records in descending order, making data analysis more convenient and insightful.


order by ascending sql
sql order by specific sequence
sql order by clause with descending order with where clause
sql order by clause with descending order multiple columns
sql order by clause with descending order
sql order by descending not working
sql order by descending example
sql order by descending syntax
group by and order by in sql
sql order of operations
sql order by clause with descending order w3schools
sql order by clause with descending order example
sql order by clause with descending order oracle
sql order by clause with descending order multiple columns

Post Views: 714
SQL Tutorial Tags:arrange data in ascending order, arrange data in descending order, ascending and descending order, ascending and descending order in sql, ascending order, descending, oracle sql order by clause, order by, order by clause, order by clause in sql, order by clause in sql ascending, order by clause in sql in hindi, order by in sql, sort data in descending order in sql, sql order by, sql order by clause

Post navigation

Previous Post: How to Convert Text to Speech in Python
Next Post: Bubble Sort in Python

More Related Articles

SQL SELECT RANDOM SQL SELECT RANDOM: Fetching Random Rows from a Database SQL Tutorial
SQL USE Database Statement - SQL USE Database Statement SQL USE Database Statement SQL Tutorial
SQL WHERE Clause SQL WHERE Clause in SQL DML Statements SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Understanding the SQL DELETE Statement and Its Variants
  2. SQL Temporary Tables: A Handy Tool for Developers
  3. SQL SELECT TOP Clause: A Comprehensive Guide
  4. SQL UPDATE with JOIN
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,612)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,210)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,862)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme