select m.Flot,n.Fop,(select nvl(sum(Fqty),0) from A where Flot=m.Flot and Fop=n.Fop) Fqty from (select distinct Flot from D) m,(select distinct C.Fop from D,B,C where D.Flot=B.Flot and B.Froute=C.Froute) n

解决方案 »

  1.   

    从要求来看,D表用不到
    select x.flot, x.fop, nvl (sum (a.fqty)) sumfqty
      from (select b.flot, c.fop
              from b, c
             where b.froute = c.froute) x, a
     where x.flot = a.flot(+) and x.fop = a.fop(+);
      

  2.   

    需要D表吧,“D表中Flot对应在B表中的Froute记录下的Fop记录都要带出”,即只取test01、test02、test03对应的Froute,而不取test04对应的Froute。