user3439263
user3439263

Reputation:

user-defined ordering in SQL

I have the field status as enum(1,2,3,4,5) and i need to order 2,3 DESC and then 1,4,5 DESC. The resul must be 3,2,5,4,1

Upvotes: 0

Views: 71

Answers (1)

Jeremy Cook
Jeremy Cook

Reputation: 22073

Arbitrary order by:

order by case [enum]
  when 3 then 1
  when 2 then 2
  when 5 then 3
  when 4 then 4
  when 1 then 5
end

Upvotes: 1

Related Questions