declare @table table (name nvarchar(4))
insert into @table
select '张三' union all
select '李四' union all
select '王五' union all
select '刘三' union all
select '杨二' union all
select '胡八' union all
select '赵六'

--方法1:
create table #t (id int identity(1,1),name nvarchar(4))
insert into #t(name) select * from @table

select a.name,b.name from #t a left join #t b on a.id=b.id-1 where a.id%2<>0

drop table #t

--方法2:
select identity(int, 1,1) AS id ,name
into #tt
from @table

select a.name, b.name
from #tt a left join #tt b on a.id = b.id-1
where a.id %2 <> 0

drop table #tt

其实是同一个方法.

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2022-03-13
  • 2022-02-18
  • 2021-11-24
  • 2022-12-23
猜你喜欢
  • 2021-09-21
  • 2022-02-07
  • 2021-09-25
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
  • 2021-08-10
相关资源
相似解决方案