Posted By

dotNetkow on 02/16/11


Tagged

sql server


Versions (?)

Specify order of rows returned in MS SQL Server


 / Published in: SQL
 

Similar to "FINDINSET" from MySQL.

  1. SELECT Name
  2. FROM People
  3. WHERE Name IN ('Bob', 'Mary', 'Joe')
  4. ORDER BY
  5. CASE Name
  6. WHEN 'Mary' THEN 1
  7. WHEN 'Joe' THEN 2
  8. WHEN 'Bob' THEN 3
  9. END

Report this snippet  

You need to login to post a comment.