SELECT
*
FROM
Table
ORDER BY
CASE catID
WHEN 10 THEN 1
WHEN 3 THEN 2
WHEN 5 THEN 3
WHEN 1 THEN 4
WHEN 7 THEN 5
WHEN 4 THEN 6
WHEN 9 THEN 7
WHEN 2 THEN 8
WHEN 6 THEN 9
WHEN 8 THEN 10
END
There might be an even more efficient way, but at least this relegates the
logic to one query.
Andy
-----Original Message-----
From: Mark W. Breneman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 09, 2004 1:24 PM
To: CF-Talk
Subject: SQL custom Order by
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.
Thanks for the help.
Mark W. Breneman
-Cold Fusion Developer
-Network Administrator
Vivid Media
[EMAIL PROTECTED]
www.vividmedia.com
608.270.9770
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

