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。
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。
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
from a A
otherwise, correct SQL construction is impossible.