求最新是条记录之和,百度怎么也没收缩到,麻烦指点,立即结贴。
------解决方案--------------------
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
--这样试一下