日期:2014-05-17 浏览次数:20531 次
--> 测试数据: @TB declare @TB table (ID int identity(1,1),SID int,TDate datetime,Grade int) insert into @TB select 2,'2012-01-01',83 union all select 3,'2012-02-01',59 union all select 4,'2012-04-01',89 select * from @TB insert into @TB select 5,getdate(),(select top 1 Grade from @TB order by TDate desc) select * from @TB /* ID SID TDate Grade ----------- ----------- ----------------------- ----------- 1 2 2012-01-01 00:00:00.000 83 2 3 2012-02-01 00:00:00.000 59 3 4 2012-04-01 00:00:00.000 89 4 5 2012-08-12 18:52:33.747 89 */
------解决方案--------------------