T-SQL Tutorial

SQL Order By


Order By Syntax:

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC

Store table:

OBJECT_IDPRICENAME
1200A
2500B
3900C
4500D

Example 1:

SELECT * FROM store
ORDER BY price, name;

OBJECT_IDPRICENAME
1200A
2500B
4500D
3900C

Example 2:

SELECT * FROM store
ORDER BY name DESC;

OBJECT_IDPRICENAME
4500D
3900C
2500B
1200A