哪就简单,只要把当前数据类型修改为字符型: SQL> create table aa (num number,str varchar2(10));Table createdSQL> insert into aa values(1001,'1001');1 row insertedSQL> insert into aa values(1001001,'1001001');1 row insertedSQL> insert into aa values(1002,'1002');1 row insertedSQL> select num from aa order by num; NUM ---------- 1001 1002 1001001SQL> select str from aa order by str;STR ---------- 1001 1001001 1002当数值型不能达到你要求,当字符型就能达到你的要求
不知道你表中數據到底怎樣,我猜想你的查詢的輸出過程是這樣的: 1.1001,1002 2.1001001,1003,1003001 3.1002001,1003002 你可以這樣寫: select departmentcode from ( select departmentcode from department order by ordercode(0) ) order by departmentcode ;
SQL> create table aa (num number,str varchar2(10));Table createdSQL> insert into aa values(1001,'1001');1 row insertedSQL> insert into aa values(1001001,'1001001');1 row insertedSQL> insert into aa values(1002,'1002');1 row insertedSQL> select num from aa order by num; NUM
----------
1001
1002
1001001SQL> select str from aa order by str;STR
----------
1001
1001001
1002当数值型不能达到你要求,当字符型就能达到你的要求
1.1001,1002
2.1001001,1003,1003001
3.1002001,1003002
你可以這樣寫:
select departmentcode
from (
select departmentcode
from department
order by ordercode(0)
)
order by departmentcode ;