All of Query was successfully tested and running well on Microsoft SQL Server 2008

Senin, 03 September 2012

sql sort order

SQL Server Order by Statement
SELECT ColumnName(s) FROM TableName Order by ColumnName Asc|Desc

Example 1:
--ascending order
select ('Rudi')FootBallTeam union
select ('Anton') union
select ('Budi') union
select ('Cahya') union
select ('Yahya') Order by FootBallTeam Asc

#Results:
FootBallTeam
Anton
Budi
Cahya
Rudi
Yahya

Example 2:
--descending order
select ('Rudi')FootBallTeam union
select ('Anton') union
select ('Budi') union
select ('Cahya') union
select ('Yahya') Order by FootBallTeam Desc

#Results:
FootBallTeam
Yahya
Rudi
Cahya
Budi
Anton

Tidak ada komentar:

Posting Komentar