日期:2014-05-16 浏览次数:20585 次
drop table t
create table t
(
id int,
num decimal(10,2),
CreateDate time
)
insert into t values (1,1,GETDATE())
waitfor delay '00:00:01'
insert into t values (1,2,GETDATE())
waitfor delay '00:00:01'
insert into t values (1,3,GETDATE())
waitfor delay '00:00:01'
insert into t values (1,4,GETDATE())
insert into t values (1,5,GETDATE())
waitfor delay '00:00:01'
insert into t values (1,6,GETDATE())
waitfor delay '00:00:01'
select SUM(t.num) from
(select top 5 * from t order by CreateDate) t
--这样试一下