按class类型归类求解total=a-b-c, 如
class a b c total
a1 10 5 5
a2 50 10 30
a1 10 10 10
a1 30 5 5
a2 10 5 5
a3 100 0 10
a2 10 10 10
a3 10 5 0 结果是怎样?
class a b c total
a1 10 5 5
a2 50 10 30
a1 10 10 10
a1 30 5 5
a2 10 5 5
a3 100 0 10
a2 10 10 10
a3 10 5 0 结果是怎样?
alter table tb add id int identity
update a set total = (select sum(a-b-c) from tb where a.id >=id) from tb a
alter table tb drop column id
比如
class a b c total
a1 10 5 5 0
a2 50 10 30 10
a1 10 10 10 -10
a1 30 5 5 10
alter table tb add id int identity
update a set total = (select sum(a-b-c) from tb where a.class = class and a.id >=id) from tb a
alter table tb drop column id