Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Anwenden der Where-Klausel für Order by in SQL

Dies sollte einen Trick machen:

SELECT
   EmpId, EmpLotusNotes
FROM 
   dbo.Table
ORDER BY
   CASE 
      WHEN EmpLotusNotes LIKE '%Japan' THEN 1
      WHEN EmpLotusNotes LIKE '%China' THEN 2 
      WHEN EmpLotusNotes LIKE '%India' THEN 3
      WHEN EmpLotusNotes LIKE '%USA' THEN 4
   END