通常排序按照值大小排序,但有时候也有例外的时候,比如按照IN 列表位置排序。
SQL> create table tt(id number(5));
Table created.
SQL> insert into tt values(1);
1 row created.
SQL> insert into tt values(3);
1 row created.
SQL> insert into tt values(9);
1 row created.
SQL> insert into tt values(4);
1 row created.
SQL> commit;
Commit complete.
--不排序的情形
SQL> select * from tt;
ID
----------
1
3
9
4
-- IN 位置排序
SQL> select id
2 from tt
3 where id in (9,4,3,1)
4 order by instr('9,4,3,1',id);
ID
----------
9
4
3
1