比如说表A,有一个varchar2(50)字段a,数据如下:
a
-------------
29874
49a409b
k0283
487
bm
93如何写一个sql语句把只含有数值的行检索出来?
我想得到的结果是:a
-------------
29874
487
93(注:49a409b、k0283、bm都包含有字母,故不是我想要的结果!)

解决方案 »

  1.   

    create table a(a varchar2(20));
    insert into a values('29874');
    insert into a values('49a409b');
    insert into a values('k0283');
    insert into a values('487');
    insert into a values('bm');
    insert into a values('93');
    commit;select a from a where nvl2(replace(translate(a,'.0123456789','000000000000'),'0',''),'字符','数字')='数字';
    A
    --------------------
    29874
    487
    93
      

  2.   

    where nvl2(replace(translate(a,'.0123456789','000000000000'),'0',''),'字符','数字')='数字';
    不是很明白'字符','数字'??????
      

  3.   

    nvl2 的作用
    nvl(a,b,c)如a为空就取b,不为空就取C