select a.id, sum(a.allcount),nvl(sum(b.addcount),0),nvl(sum(c.removecount),0)
from table1 a, table2 b, table3 c
where a.id = b.id (+) and a.id=c.id(+)
group by a.id

解决方案 »

  1.   

    好象不行啊,where a.id = b.id (+) and a.id=c.id(+)和where a.id = b.id and a.id=c.id的效果一样啊,只能列出当时又有出库又有入库的货物
      

  2.   

    insert into table4 select a.id,sum(allcount),sum(select addcount from table2 where id=a.id),sum(select removecount from table3 where id=a.id) from table1 a group by id;若是这样,那每次要从三个表统计再插入table4,最好还是增加一个日期型字段.
      

  3.   

    我以为你的table1(id, allcount)中包含了所有物品,如果没有,就找一个包含所有物品的表,其他表和他外连接。
      

  4.   

    先按table1,table2,table3的顺序左连,忽略重复记录联合(union) 按tabl2,table1,table3的顺序左连,再忽略重复记录联合(union) 按tabl3,table2,tabl1的顺序左连