哪位大侠能给我解决这个问题  谢谢了
表 T1 (Key1 int, CreateTime date) , 表 T2(Key2 int, CreateTime date),取最近10天来的记录中, T1中有,而T2中不存在的记录。两表连接: T1. Key1 = T2. Key2
(不要使用 not in 之类的低效率语句)

解决方案 »

  1.   


    SELECT t1.* FROM t1 
    WHERE NOT EXISTS(SELECT 1 FROM t2 WHERE T1.Key1 = T2.Key2) 
    AND t1.CreateTime BETWEEN SYSDATE-10 AND SYSDATE;
      

  2.   


    select key1,createtime
    from t1
    where t1.createtime<=sysdate-10
    and not exists(select 1 from t2 
                     where t1.key1=t2.key2 
                     and t1.createtime=t2.createtime)
      

  3.   

    应该是t1.createtime>=sysdate-10
      

  4.   

    select t1.*
    from t1
       left join t1 on t1.id=t2.id
    where t2.id is null