SQL Server Custom ORDER BY – How to Implement in SSMS

order-bysql serversql-server-2008ssms

Are there other ways to use ORDER on my results?

20150507094958A DISPOSED        2015-05-07 09:50:00.853 Samuel  MONEY
20150507094958A DISPOSED        2015-05-22 09:25:00.000 Jeff    AUTOMOBILES
20150507094958A DISPOSED        2015-05-26 09:39:00.000 Joel    FIREARMS
20150507094958A DISPOSED-READY  2015-05-29 09:57:00.000 Samuel  MONEY
20150706132447A OUT             2011-10-19 11:25:00.000 Samuel  AUTOMOBILES
20150406110457A OUT             2015-04-02 11:07:00.000 Shane   FIREARMS
20150406105740A OUT             2015-04-06 11:00:00.000 Cordero FIREARMS
20150406105740A IN              2012-03-27 21:15:00.000 Alex    BICYCLES

I want to get all the FIREARMS on the top and then still order by any other column.

Best Answer

There are several ways to do it. However, this may work for you:

select 
    myTable.* 
from myTable
order by (case myCol when 'FIREARMS' then '' else myCol end);