双top的问题
declare @table1 table (id int)insert into @table1select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 ;witha as ( select top(5)id from @table1)select top(1)id from a order by id desc
select top(1)id from( select top(5)id from @table1) a order by id desc
declare @table1 table (id int)insert into @table1select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 ;witha as ( select top(5)id from @table1 order by id)select top(1)id from a order by id desc/*(8 行受影响)id-----------5(1 行受影响)*/