T-SQL help - order by a particular value

Soldato
Joined
1 Feb 2006
Posts
8,188
I have a fairly huge T-SQL stored proc that I need to update for a colleague. There are a load of different values in one column such as open, created, pending etc.

I want to sort the results so that 'pending' is returned first. Obviously I can't use ASC or DESC here. Is there any easy, quick and obvious way to do this that I am missing completely?
 
Thanks I got this sorted in the meantime. I used a ORDER BY CASE WHEN something THEN 1 ELSE 2 END, fieldname. Found it in google and it worked.
 
Back
Top Bottom