Learn Sql Server   Learn Sql Theory   Learn Sql

 
Chapter 1

Learn Sql Server

Select Statement

Sql Server Order By

Sql Server Asc Desc

Sql Server Where

Sql Server Operators

Sql Server Create Table

Sql Server Insert Statement

Sql Server Update

Sql Server Delete

Sql Server Count

Sql Server NULL

Sql Server RowCount

Sql Server SUM

Sql Server Average

Sql Server MIN MAX

Sql Server ROUND

Sql Server Ceiling

Sql Server Floor

Sql Server Sqrt

Sql Server Top

Sql Server BOTTOM

Sql Server Tie

Sql Server Distinct

Sql Server SUBSTRING

Sql Server LEFT RIGHT

Sql Server String Concatenation

Sql Server Data Types

Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16

Ascending and Descending Order in Sql Server

Syntax:

SELECT columns
FROM tables
WHERE yourcondition
ORDER BY column ASC/DESC;

ASC/DESC is used with ORDER BY clause which sorts the result set based on the columns specified. If the ASC or DESC value is omitted, it is sorted by ASC.
ASC indicates ascending order. (default)
DESC indicates descending order.

Sponsored links

Suppose we have tbl_emp with some data.

tbl_emp

NameAge
Rahul30
monika25
Paul50

Then use below query and find result set.

SELECT name, age FROM tbl_emp ORDER BY age ASC

Result:

NameAge
monika25
Rahul30
Paul50

In the above query we have displayed data in Ascending order with ASC keyword with order by. If you want to display your data in descending order then you can use the keyord DESC with order by clause in sql server which is explained as follows:

SELECT name, age FROM tbl_abc ORDER BY age DESC

Result:

NameAge
Paul50
Rahul30
monika25

In SQL Server when you write any select query it display the data Ascending order without mentioning the asc keyword in query because by default it display the data in ascending order.

Sponsored Links