Microsoft SQL Server Custom Ordering


Example

If you want to order by a column using something other than alphabetical/numeric ordering, you can use case to specify the order you want.

order by Group returns:

GroupCount
Not Retired6
Retired4
Total10

order by case group when 'Total' then 1 when 'Retired' then 2 else 3 end returns:

GroupCount
Total10
Retired4
Not Retired6