Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Order Results By Column Number

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-13 : 07:23:47
greg writes "Hi there

For the purposes or ordering content dynamically I need to know if and how I can order a sql statement by the column number as apposed to the column name. I suppose it would be the same as selecting a column by the number instead of the name...

Any ideas how I can do this? Appreciate any help...

Cheers"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-04-13 : 07:23:33
You've already answered it, simply use ORDER BY n where n is the number of the column you want to order by.

BTW, you cannot SELECT by column number, in fact ORDER BY is the only clause that uses column numbers.
Go to Top of Page
   

- Advertisement -