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)
 Variable ORDER BY clause

Author  Topic 

zgaddo
Starting Member

3 Posts

Posted - 2005-01-26 : 09:07:20
Hi there. I want to write a select statement with order by clause which sorts the table according different field any time it is called:

SELECT * FROM MyTable
ORDER BY 1,3,4

SELECT * FROM MyTable
ORDER BY 3,2

SELECT * FROM MyTable
ORDER BY 2
and so on...

Any of the preceding cases must be done with a single SELECT statement
without knowing the ORDER BY fields in advance (there may be no fields to sort at all). Thank you.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-26 : 09:22:50
this should help you:
http://www.sqlteam.com/item.asp?ItemID=2209

Go with the flow & have fun! Else fight the flow
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-01-26 : 09:24:07
You need to let us know when you know what the sort order is?



Brett

8-)
Go to Top of Page

zgaddo
Starting Member

3 Posts

Posted - 2005-01-27 : 07:41:10
The only thing I know is which MAY BE the sorting fields, but I don't know the exact fields and their order.
Go to Top of Page

zgaddo
Starting Member

3 Posts

Posted - 2005-01-27 : 09:28:08
Forget it. I'm sorry for wasting your time. No SQL ordering can work with Crystal Reports.
Go to Top of Page
   

- Advertisement -