create table testDB
(
id int identity(1,1) primary key,
name varchar(20) not null,
sales dec(18,2)
)
insert into testDB values('张三',10)
insert into testDB values('李四',20)
insert into testDB values('王五',30)
insert into testDB values('赵立权',40)
insert into testDB values('张华',50)
insert into testDB values('周杰',60)
select * from testDB
select id,name,sales,(select sum(sales) from testDB where id<=a.id) as 'total' from testDB a