例如有下列号码。
13309098899
12398987789
13409098888
.。。
等等,就是我们平常用到的手机号码。
现有一下要求。大家觉得用什么方式做比较好。
如果用SQL,希望大家提供一些比较好的语句,特别是1.尾数为88
2.尾数为为ABAB,比如说1010
3.尾数为AABB,比如说1100
4.尾数为等差数列,差额为正1或者负1,比如5678,9876 ,3210,0123
5.除以上四种的其他

解决方案 »

  1.   

    只想到了用substr,
    观望中。
      

  2.   

    1.select tel from tel_table where instr(tel,'88',-1,1) = 10;
    2.select tel from tel_table
    where substr(tel,8,2) = substr(tel,10,2)
    and substr(substr(tel,8,2),1,1) <> substr(substr(tel,8,2),2,1)
    ;
    3.select tel from tel_table
    where substr(tel,8,2) <> substr(tel,10,2) 
    and substr(tel,8,2) in 
    (select lpad((rownum-1||rownum-1),2,'0')  from tel_table connect by rownum <=9)
    and substr(tel,10,2) in 
    (select lpad((rownum-1||rownum-1),2,'0')  from tel_table connect by rownum <=9)
    ;
    4.select tel from tel_table
    where substr(tel,8,4) in
    (
    select lpad((rownum-1||rownum||rownum+1||rownum+2),4,'0')  from tel_table
    connect by rownum <=7
    union 
    select lpad((rownum+2||rownum+1||rownum||rownum-1),4,'0') from tel_table
    connect by rownum <=7
    );
    5.select tel from tel_table
    minus
    (1的结果
    union
    2的结果
    union
    3的结果
    union 
    4的结果
    )
    ;