declare @a table(A int,B int) insert @a select 1, 2 union all select 2 ,3select * from (select top 1 * from @a order by a) aa cross join (select top 1 * from @a order by a desc) bb
select a.*,b.* from tablename a,tablename b where b.id=a.id+1 and (a.id %2)=1 and (b.id %2)=0
insert @a select 1, 2
union all select 2 ,3select * from
(select top 1 * from @a order by a) aa
cross join
(select top 1 * from @a order by a desc) bb
from tablename a,tablename b
where b.id=a.id+1
and (a.id %2)=1
and (b.id %2)=0