select a.startno,a.endno from hdb a,hdb b where a.endno-a.startno<b.endno-b.startno

解决方案 »

  1.   

    谢谢楼上的回答。
    可是你的答案不对,最起码你的sql会产生迪卡尔积呀。
      

  2.   

    对于重复记录,可以用DISTINCT方法去除 ,如
    select DISTINCT a.startno,a.endno from hdb a,hdb b where a.endno-a.startno<b.endno-b.startno
      

  3.   

    上面算法有问题:select distinct a.startno,a.endno from hdb a,hdb b where a.rowid<>b.rowid and (b.endno>=a.startno and b.endno<=a.endno);
      

  4.   

    这里有求重复记录的最好算法。可以查出指定重复的列的记录
    http://www.oradb.net/sql/find0.htm
      

  5.   

    select * from hdb x
     where exists (select 'x' from hdb
                    where rowid != x.rowid
                      and (startno between x.startno and x.endno
                           or endno between x.startno and x.endno));