您的位置:首页 > 数据库 > Oracle

Oracle order by case when 多条件排序

2016-03-05 00:22 393 查看
ORACLE sql 排序 根据两个条件排序,根据id号由小到大排序,同时country字段是北京的排最前面前面,其次上海,。。大连,最后是其他城市,怎么写?

写法如下:
select * from provice
order by (case when country='北京' then 0
when country='上海' then 1
when country='广东' then 2
when country='深圳' then 3
when country='杭州' then 4
when country='大连' then 5
else 6 end) ,id desc
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: