Suppose we have StateCity table.
Now we want to in a order that State NY is first and Else in Alphabetic Order here is the Query :
Select * from StateCity
Order By Case When
[State] =
'NY' Then '1'
When [State] = 'NJ' Then '2'
Else
[State] END
ASC
Result:
Suppose you want to Order By Particular State and Particular City here is the example of the Query :
Select * from StateCity
Order By Case
When [State] = 'NY' Then '1'
When
[State] =
'NJ' Then '2'
Else
[State] END
ASC,
Case
When [City] = 'New York' Then '1'
When [City] = 'Atlanta' Then '1'
When [City] = 'Parsippany' Then '1'
Else
[City] END ASC
Result: