日期:2014-05-18 浏览次数:20506 次
create table A(B int) insert into A values(1) insert into A values(5) insert into A values(-3) insert into A values(2) insert into A values(5) insert into A values(3) insert into A values(-2) insert into A values(-8) create table B(B int) go select B , id = identity(int,0,1) into tmp from A insert into B select 结果 from (select id = id/4 , 结果 = sum(B) from tmp group by id/4) t select * from B drop table A,B,tmp /* B ----------- 5 -2 (所影响的行数为 2 行) */