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 Ascending Order

SQL ORDER BY Clause with Ascending Order

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

SQL ORDER BY Clause with Ascending Order

Whenever we want to sort the records based on the columns stored in the tables of the SQL database, we use the ORDER BY clause in SQL. This clause helps us organize records based on a specific column in a table. Initially, all the values stored in the selected column will be sorted, and then the corresponding rows will be displayed in the same order.

The ORDER BY clause allows us to sort records in ascending or descending order. When we use the ASC keyword, the sorting is in ascending order, while the DESC keyword sorts in descending order. If no keyword is specified, the sorting is done in ascending order by default.

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

Syntax to Sort Records in Ascending Order

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

Syntax without Using ASC Keyword (Defaults to Ascending Order)

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

Let’s explore this further with some examples using a MySQL database.

Example 1: Sorting by Customer Name

Consider a customers table with the following records:

IDNameAgeAddressSalary
1Aman Sharma27Delhi30000
2Priya Verma24Mumbai40000
3Ravi Kapoor35Kolkata55000
4Neha Singh29Bangalore42000
5Rajesh Kumar41Hyderabad60000

Query to Sort Customers by Name in Ascending Order:

SELECT * FROM customers ORDER BY Name ASC;

Output:

IDNameAgeAddressSalary
1Aman Sharma27Delhi30000
4Neha Singh29Bangalore42000
2Priya Verma24Mumbai40000
5Rajesh Kumar41Hyderabad60000
3Ravi Kapoor35Kolkata55000

All records are sorted alphabetically by the Name column.

Example 2: Sorting by Address in Ascending Order

SELECT * FROM customers ORDER BY Address;

Output:

IDNameAgeAddressSalary
4Neha Singh29Bangalore42000
1Aman Sharma27Delhi30000
5Rajesh Kumar41Hyderabad60000
3Ravi Kapoor35Kolkata55000
2Priya Verma24Mumbai40000

Example 3: Sorting by Salary in Ascending Order

SELECT * FROM customers ORDER BY Salary ASC;

Output:

IDNameAgeAddressSalary
1Aman Sharma27Delhi30000
2Priya Verma24Mumbai40000
4Neha Singh29Bangalore42000
3Ravi Kapoor35Kolkata55000
5Rajesh Kumar41Hyderabad60000


Example 4: Sorting by Age in Ascending Order

SELECT * FROM customers ORDER BY Age;

Output:

IDNameAgeAddressSalary
2Priya Verma24Mumbai40000
1Aman Sharma27Delhi30000
4Neha Singh29Bangalore42000
3Ravi Kapoor35Kolkata55000
5Rajesh Kumar41Hyderabad60000

Sorting Data in Another Table (Agents Table)

Consider the agents table with the following records:

AIDNameWorkAreaProfit_PercentContactNumberSalary
1Ankit JainDelhi5989812345642000
2Ravi KumarMumbai3987654321038000
3Priya SharmaKolkata7976543210950000
4Rakesh VermaBangalore4965432109845000
5Neha GuptaHyderabad6954321098747000

Query to Sort Agents by Name in Ascending Order:

SELECT * FROM agents ORDER BY Name ASC;

Output:

AIDNameWorkAreaProfit_PercentContactNumberSalary
1Ankit JainDelhi5989812345642000
5Neha GuptaHyderabad6954321098747000
3Priya SharmaKolkata7976543210950000
4Rakesh VermaBangalore4965432109845000
2Ravi KumarMumbai3987654321038000

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

Conclusion

The ORDER BY clause is essential for organizing and analyzing SQL data efficiently. By default, it sorts records in ascending order, and when paired with the ASC keyword, it explicitly maintains that order. Understanding this clause enables users to retrieve structured and meaningful data from their database tables effortlessly.

By leveraging ORDER BY, businesses can enhance data reporting, improve database navigation, and optimize queries for a better data retrieval experience.


group by clause in sql
order by ascending sql
order by ascending sql
sql order by specific sequence
sql order by clause with ascending order where clause
sql order by clause with ascending order
sql order by ascending where
sql order by clause with ascending order and where clause
sql order by ascending syntax
sql order by clause with ascending order multiple columns
group by and order by in sql
sql order by date
sql order by clause with ascending order w3schools
sql order by clause with ascending order example
sql order by clause with ascending order oracle
sql order by clause with ascending order multiple columns

Post Views: 524
SQL Tutorial Tags:clause, clause commands, clauses in sql, clauses mysql, group by clause, mysql order by clause, oracle sql order by clause, order by clause, order by clause in dbms, order by clause in hindi, order by clause in sql

Post navigation

Previous Post: Strong Number in Python
Next Post: Store POS Java Project

More Related Articles

SQL SELECT from Multiple Tables SQL SELECT from Multiple Tables SQL Tutorial
SQL DROP DATABASE: A Comprehensive Guide - SQL DROP DATABASE SQL DROP DATABASE: A Comprehensive Guide SQL Tutorial
SQL RIGHT JOIN SQL RIGHT JOIN: A Comprehensive Guide 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