简体   繁体   English

用户定义的SQL排序

[英]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 . 我的字段状态enum(1,2,3,4,5) ,我需要先order 2,3 DESC然后order 2,3 DESC 1,4,5 DESC The resul must be 3,2,5,4,1 结果必须为3,2,5,4,1

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM