表A ID  面积  金额 表B ID  NEWID(录入表A中的一个ID)  OLDID(录入表A中的一个ID) 需要 根据表B中的 NEWID  和 OLDID  找到表A中对应的面积 金额   用 OLD面积 -  NEW面积   用OLD金额 - NEW金额

解决方案 »

  1.   


     select (select square from A where id = oldId) - (select square from A where id= newId) OLD面积 - NEW面积, (select money from A where id = oldId) - (select money from A where id=newId)  用OLD金额 - NEW金额 from dual
     
      

  2.   


    select (select square from A where id = oldId) - (select square from A where id= newId) (OLD面积 - NEW面积), (select money from A where id = oldId) - (select money from A where id=newId)  (用OLD金额 - NEW金额) from dual
      

  3.   

    把A表做个别名,直接查询就行了
    select b.newid,a.area,a.money,b.oldid,c.area,c.money,c.area - a.area,c.money - a.money
    from A a,B b,A c
    where b.newid=a.id
    and b.oldid=c.id
      

  4.   


    select t1.id, t1.面积 - t2.面积, t1.金额 - t2.金额
      from (select 表B.id, 面积, 金额 from 表B,表A where 表B.newid = 表A.id) t1,
           (select 表B.id, 面积, 金额 from 表B,表A where 表B.oldid = 表A.id) t2
     where t1.id = t2.id
      

  5.   


    select a2.cost-a1.cost, a2.area-a1.area 
      from A a1, A a2, B b
        where a1.ID=b.NEWID and a2.ID=b.OLDID
      

  6.   

    在mysql下测试通过的。oracle应该也没有问题。