select *  from TABLE t
where t.sn not in
      ( select b.sn from TABLE b ,TABLE c
        where b.source = c.source 
          and b.sn !=c.sn and b.status = 'Z'
          and  c.end_time = b.start_time )

解决方案 »

  1.   

    select *  from TABLE t
    where not exists 
          ( select 1 from TABLE b ,TABLE c
            where t.sn =b.sn and b.source = c.source 
              and b.sn !=c.sn and b.status = 'Z'
              and  c.end_time = b.start_time )
      

  2.   

    to:  libin_ftsafe(子陌红尘:TS for Banking Card) 
    ------------------------------------------------
    感谢!不过数据太大,执行很慢,不出结果,还有办法没有?
    ------------------------------------
    select *  from TABLE t
    where t.sn not in    --当为t.sn in 时,很快能得到数据,加入not,
                         --查询太慢,出不来结果,老大们帮想想办法
          ( select b.sn from TABLE b ,TABLE c
            where b.source = c.source 
              and b.sn !=c.sn and b.status = 'Z'
              and  c.end_time = b.start_time )
      

  3.   

    select   *     from   TABLE   t 
    where   not   exists   
                ( select   1   from   TABLE   b   ,TABLE   c 
                    where   t.sn   =b.sn   and   b.source   =   c.source   
                        and   b.sn   !=c.sn   and   b.status   =   "Z" 
                        and     c.end_time   =   b.start_time   )
      

  4.   

    改为not exists,再对相应的查询字段建索引