日期:2014-05-18 浏览次数:20450 次
--> 测试数据:[test] if object_id('[test]') is not null drop table [test] create table [test]( [ID] int, [时间] varchar(5), [压力] int, [温度] int, [湿度] int ) insert [test] select 1,'time1',10,15,20 union all select 2,'time2',11,16,21 union all select 3,'time3',12,17,22 union all select 4,'time4',13,18,23 union all select 5,'time5',14,19,24 update test set [压力]=t.[压力] from( select px=ROW_NUMBER()over(order by getdate()), [压力] from test where [时间] in('time4','time5') )t where test.ID=t.px select * from test /* ID 时间 压力 温度 湿度 1 time1 13 15 20 2 time2 14 16 21 3 time3 12 17 22 4 time4 13 18 23 5 time5 14 19 24 */ 说实话,你给的这个测试数据的时间字段让人很蛋疼