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
写法如下:
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
相关文章推荐
- Oracle命令(一):Oracle登录命令
- oracle体系结构 非常详细
- window系统Oracle10安装教程
- Oracle X2-2 一体机Solaris 平台最佳实践 (文档 ID 2009867.1)
- RAC 和 Oracle Clusterware 最佳实践和初学者指南(平台无关部分) (文档 ID 1526083.1)
- Mount Options for Oracle files when used with NFS on NAS devices (文档 ID 359515.1)
- RAC 和 Oracle Clusterware 最佳实践和初学者指南 (Solaris) (文档 ID 1526517.1)
- Oracle ORA-12541:TNS:no listener
- pb程序在64位操作系统上使用Instant Client 连接oracle数据库
- oracle 自动关闭 数据库连接
- oracle 11g dblink 查询的bug --10053用处
- Oracle和Sql 日期格式与字符串格式相互转换
- 理解一下ORACLE数据库
- Oracle9I新增语法 merge into
- ORACLE不常用但实用的技巧- 树查询 level用法
- Oracle 常用系统包(转)
- ORACLE中 %TYPE 和 %ROWTYPE 的使用
- [转载]oracle建表语句大全
- 不安装oracle客户端,如何运行sqlplus
- dos命令行连接数据库 oracle11g