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 )
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 )
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 )
------------------------------------------------
感谢!不过数据太大,执行很慢,不出结果,还有办法没有?
------------------------------------
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 )
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 )