本帖最后由 SkyMyth 于 2009-12-22 13:56:08 编辑

解决方案 »

  1.   

    select A.订单号,B.出库单号,B.出库日期,C.签字状态 … from A t Left join B on A.id = B.id left join C on B.idd = c.idd 
    where exists(select 1 from a t1,b t2,c t3
        where t1.id=t2.id and t2.idd=t3.idd and t3.签字状态='3' and t1.订单号=t.订单号)这样试试
      

  2.   

    谢谢
    但是这条
    SO00001    null      null  1004  … 
    还是没出来
      

  3.   

    select A.订单号,B.出库单号,B.出库日期,C.签字状态 … 
    from A Left join B on A.id = B.id left join C on B.idd = c.idd 
    where exists
    (
    select 1 from a t1,b t2,c t3 
    where t1.id=t2.id and t2.idd=t3.idd and t3.签字状态='3'
    )这样试试呢
      

  4.   

    不会吧
    那这么写呢
    select * from(
    select A.订单号,B.出库单号,B.出库日期,C.签字状态 …,max(decode(c.签字状态,'3',1,0))over(partition by a.订单号)m from A Left join B on A.id = B.id left join C on B.idd = c.idd 
    )
    where m=1
    试试
      

  5.   

    select *
    from (select A.订单号,B.出库单号,B.出库日期,C.签字状态 … 
    from A Left join B on A.id = B.id left join C on B.idd = c.idd )
    where nvl(签字状态,3) = 3;以为签字状态为3是B,C两表所加的影响,而为NULL是A表纪录的原因,如果在B,C表上加条件则无法取出A表数据,如果对A表做条件则无法取出=3的纪录,如果A,B,C表联合条件则无法取出完整结果。简易方式,在你本身的SQL外层包装一下。
      

  6.   

    楼上的!nvl(签字状态,3) = 3 则会把整单未发的 也带出来,因为整单未发的 签字状态为 null不过有启发 就是先过滤掉整单未发的,再加上你这个条件!谢谢
      

  7.   

    select *
    from (select A.订单号,B.出库单号,B.出库日期,C.签字状态 … 
    from A Left join B on A.id = B.id left join C on B.idd = c.idd )
    where nvl(签字状态,3) and 签字状态 is not null ;