This could be a freak accident that this works for me.. But it did in SQL
2000. This may not be the most efficient way of doing this either.
SELECT *
FROM category
WHERE
CatID = 10
union all
SELECT *
FROM category
WHERE
CatID = 3
union all
SELECT *
FROM category
WHERE
CatID = 5
union all
SELECT *
FROM category
WHERE
CatID = 1
Try it,
David
-----Original Message-----
From: Plunkett, Matt [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 09, 2004 1:39 PM
To: CF-Talk
Subject: RE: SQL custom Order by
-----Original Message-----
From: Mark W. Breneman
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.
(Not sure this is possible in Sql Server, cause I don't use that).
I would write a custom function to do this. So you would do:
select catID, mysort(catID) srt
from foo
order by srt;
In the function, just return what order you want given the catId.
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
- SQL custom Order by Mark W. Breneman
- RE: SQL custom Order by Andrew Tyrone
- RE: SQL custom Order by Plunkett, Matt
- Re: easy question David Jones
- Re: easy question Tony Weeg
- RE: SQL custom Order by Mark A. Kruger - CFG
- Re: SQL custom Order by Jochem van Dieten