update a
 set c=a.c-c.c
 from a,(select id,sum(c) as c from b group by id) as c
 where a.id=c.id说明:只保证适用SQL SERVER。

解决方案 »

  1.   

    如果是oracle
    select 
      a.id id,a.c-b.c c,a.d d 
    from 
      a a,(select id,sum(c) c from b group by id) b
    where
      a.id=b.id(+)  
    order by 
      a.id
      

  2.   

    access,很土吧?我想update 表a,怎么办?
      

  3.   

    楼上CSDN经理(肯定是个假的,不过学问应该是真的:))说的没错,应该也可以用在ASP中更新ACCESS中的表。不过看你这俩表显然是主子表,那你岂不是每当子表中插入新数据时都要如此更新一下?每次都用Group By怕不是好办法,不过ACCESS也只好这样了,如果是SQL Server则用触发器就经较好了
      

  4.   

    为什么在access中用这个update语句会说from 有错?
      

  5.   

    select A.id , (select B.c - C.c from a B, b C where A.id = B.id = C.id) , A.d
    from a A 
     
      

  6.   

    Firstly, I think you should specify the key of your table.
    otherwise, correct SQL construction is impossible.