这么写:
select a.*,
 (select sum(nvl(b.fqty, 0)) from tdaspickupstoredtl b where b.num = a.num and b.line = a.line and b.foktime is null) fremainqty
from TDASPICKUPARTDTL a, tdaspickarticle c  
where a.num = c.num and a.farticle = c.farticle
and c.stat in (0, 1) and a.num = '89180606200001'

解决方案 »

  1.   

    SELECT e.*
      FROM tdaspickarticle c,
           (SELECT a.*,SUM (NVL (b.fqty, 0)) fremainqty
              FROM tdaspickupstoredtl b,tdaspickupartdtl a
             WHERE b.num = a.num AND b.line = a.line AND b.foktime IS NOT NULL) e
     WHERE e.num = c.num
       AND e.farticle = c.farticle
       AND c.stat IN (0, 1)
       AND e.num = '89180606200001'
    试一下。
    你的sql主要是from的那个子查询找不到外层查询的a表
      

  2.   

    select a.*,
     (select sum(nvl(b.fqty, 0)) from tdaspickupstoredtl b where b.num = a.num and b.line = a.line and b.foktime is null) fremainqty
    from TDASPICKUPARTDTL a, tdaspickarticle c  
    where a.num = c.num and a.farticle = c.farticle
    and c.stat in (0, 1) and a.num = '89180606200001'
      

  3.   

    select a.*, e.fremainqty
    from TDASPICKUPARTDTL a, tdaspickarticle c,
      (select sum(nvl(b.fqty, 0)),num,line fremainqty from tdaspickupstoredtl b where b.foktime is not null group by num,line) e
    where a.num = c.num and a.farticle = c.farticle
    and c.stat in (0, 1) and a.num = '89180606200001' and 
    e.num = a.num and e.line = a.line 
      

  4.   

    写错了
    select a.*, e.fremainqty
    from TDASPICKUPARTDTL a, tdaspickarticle c,
      (select sum(nvl(b.fqty, 0 fremainqty )) fremainqty,num,line  from tdaspickupstoredtl b where b.foktime is not null group by num,line) e
    where a.num = c.num and a.farticle = c.farticle
    and c.stat in (0, 1) and a.num = '89180606200001' and 
    e.num = a.num and e.line = a.line
      

  5.   

    PowerPort(┕⊙ō⊙┙)  的回答稍微改一点关联条件:e.num = a.num and e.line = a.line
    --->
    and a.num = e.num(+) and a.line = e.line(+)