Skip to content Skip to sidebar Skip to footer

Custom Order By In Sql Server Like P, A, L, H

Not ASC or DESC.... Order by custom... I have tried using case but not successfully SELECT * FROM Customers ORDER BY case country when 'P' then 1 … This is what I want:

Solution 1:

SELECT * FROM Customers
ORDER BY case when country = 'P' then 1
              when country = 'A' then 2
              when country = 'L' then 3
              when country = 'H' then 4
              else 5
         end asc

Post a Comment for "Custom Order By In Sql Server Like P, A, L, H"