--忘记给变量了 declare @变量 intselect @变量=max(字段) from (select top n from 表 where ...)a
update 表 set 列名= XXX WHERE 字段=(select max(select top n from 表 where 列名=~~)from 表)
假定id是你表的主键 exec('update b set b.fieldname='+@你的变量值 +' from yourtable b, ( select id,max(fieldname) fieldname from (select top '+@n+' id,filedname from yourtable )a group by id )a where a.id=b.id')
declare @变量 intselect @变量=max(字段) from (select top n from 表 where ...)a
WHERE 字段=(select max(select top n from 表 where 列名=~~)from 表)
exec('update b set b.fieldname='+@你的变量值
+' from yourtable b,
(
select id,max(fieldname) fieldname
from (select top '+@n+' id,filedname from yourtable )a group by id
)a
where a.id=b.id')