create function num_asc(p_col in varchar2)
return number
as
a number;
begin
a:=to_number(p_col);
return a;
exception
when others then
return ascii(p_col)+99999999999;
end;
/
select * from tab order by num_asc(col);
return number
as
a number;
begin
a:=to_number(p_col);
return a;
exception
when others then
return ascii(p_col)+99999999999;
end;
/
select * from tab order by num_asc(col);
如果是长度为几十,那就麻烦。
select * from table order by decode(length(字段),3,字段,2,'0'||字段,'00'||字段)
----------
asd
123
12
23
3
a3已选择6行。SQL> select name from tb where ascII(name) between
2
SQL> select ascII(1),ascII(9),ascII(0) from dual; ASCII(1) ASCII(9) ASCII(0)
---------- ---------- ----------
49 57 48SQL> select name from tb where ascII(name) between 48 and 57
2 union all
3 select name from tb where ascII(name)<48 or ascII(name)>57 order by name;NAME
----------
12
123
23
3
a3
asd已选择6行。SQL>
return number
as
a number;
begin
a:=to_number(p_col);
return a;
exception
when others then
return ascii(p_col)+99999999999;
end;
/
这些写在哪里?是程序页面上,还是oracle里?