Mark W. Breneman said:
> I doubt this is possible, but is there a way to do a custom order by
> based on the order I provide?  I need the SQL results to be in a
> specific order based on the "catID", but not in ascending or
> descending order. The order that I want them in is
> 10,3,5,1,7,4,9,2,6,8.
>
> Example
>
> Select *
> From table
> Order by catID values(10,3,5,1,7,4,9,2,6,8)
>
> I am using MS SQL 2000.

If MS SQL Server 2000 has a ListFind() function that operates similar
to the ListFind() function in CF it is pretty easy:

SELECT    *
FROM      table
ORDER BY
          Cast(ListFind(CatID, '10,3,5,1,7,4,9,2,6,8') AS BOOLEAN),
          ListFind(CatID, '10,3,5,1,7,4,9,2,6,8')

If all CatID's are between 1 and 10 you can even leave the first order
condition out.

If MS SQL Server 2000 does not have such a function you might be able
to write a UDF for it or use an adapted Find() function.

Jochem
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to