select * from a
where not exists (select 'x' from b
                   where goods = a.goods
                     and type = 1
                     and operate_date > add_month(sysdate,-3));

解决方案 »

  1.   

    select goods from a where a not in 
    (select distinct goods from b where operate_date between 时间1 and 
    时间2 and type=1)
      

  2.   

    改一下:
    select goods from a where goods not in 
    (select distinct goods from b where operate_date between 时间1 and 
    时间2 and type=1)
      

  3.   

    楼上朋友的方法固然可行,但我认为用not in和not exists 这样的语句在b表数据量很大时比较浪费时间,所以小弟想了一个复杂些写法,不知可行不可行:
    select goods_a from (
      select a.goods goods_a,bb.goods goods_b from a,
        (select goods from b where operate_date between 时间1 and 时间2 and type=1) bb
       where a.goods = bb.goods(+)
      )
    where goods_b is null;
      

  4.   

    select goods from a 
    minus 
    select goods from b where operate_date between 时间1 and 时间2 and type=1