Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL sort order

Status
Not open for further replies.

jerrilynn

Technical User
Jul 9, 2001
1
US
I have inherited the SQL data with my company. Since I havent started my classes yet, i need an answer.
I have 3 columns on my table.
code
description
order by

I need assistance in sorting order for the third column.
I have looked at ascending and descending, but i must be missing something. It is not working.
please help.
thanks
 
Your column name is "order by" (with with a space)? If there is a space you would have to use double quotes if referencing the column directly in your order by clause.

SELECT ...
FROM
ORDER BY "order by"

Another method to sort is to use the ordinal value from the column list. Below sorts the result set first by col3, then col2 and then col1:

SELECT col1, col2, col3
FROM Tab1
ORDER BY 3, 2, 1

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top