本帖最后由 junon 于 2011-10-09 14:10:27 编辑

解决方案 »

  1.   

    用自身表的链接查询
    select * from tablename t1.tablename t2 where t1.B+60>t2.B or t1.B+60<t2.B or t1.B-60<t2.B or t1.B-60<t2.B(没测试过)
      

  2.   

    这个不对哦,出来100rows了。主要是现在没有主键不能用表连接啊,如果字段B是主键会不会好搞一点
      

  3.   


    select distinct ta.a,ta.b 
    from
    (select a,b,rownum rn from table1) ta,
    (select a,b,rownum rn from table1) tb
    where (ROUND(TO_NUMBER(tb.b - ta.b) * 24 * 60 * 60) > 60   and (tb.rn = ta.rn + 1 or tb.rn = ta.rn - 1));
      

  4.   

    google搜下oracle level查询!
      

  5.   

    很简单,没有主键通过rownum 生成个就行。使用分析函数lag很容易就解决了
      

  6.   

    假设有test表,有字段 a number,b date   select t.a,
             t.after_date
        from 
           ( 
              select t.a,
                     lag(t.b,1,null) over(order by t.b asc) as befor_date,
                     t.b as after_date
                from test t
           ) t
       where (t.after_date - t.befor_date) * 24 * 60 * 60 > 60
      

  7.   


    WITH T1 AS(
      SELECT 字段B,NEXT_字段B
        FROM(SELECT 字段A,字段B,LEAD(字段B,1,字段B)OVER(ORDER BY 字段B) NEXT_字段B
               FROM 表名)
       WHERE (NEXT_字段B - 字段B) * 86400 > 60
    )
    SELECT
      FROM 表名
     WHERE 字段B IN(
        SELECT 字段B FROM T1
        UNION 
        SELECT NEXT_字段B FROM T1);