各位大佬帮忙看下,在线等
sqlserver吧
全部回复
仅看楼主
level 1
xinwensheng1 楼主
现在要吧下边这个表的数据插入到上边这个空表中,下边这张表中的数据是 姓名,编号,性别……一直循环的,每3条数据一组,我现在如何将这个表中的数据添加到上边这个空表中呢,求各位大佬帮吗解答一下,感谢。
2018年03月10日 06点03分 1
level 4
这个表设计的有问题啊。不过你可以这样做,性能不敢保证了
declare @t table(cid int, Ccoten varchar(100))
insert into @t select 1,'xiaowang'
insert into @t select 2,'10001'
insert into @t select 3,'m'
insert into @t select 4,'xiaolv'
insert into @t select 5,'10002'
insert into @t select 6,'f'
select n.Ccoten name,b.Ccoten id,x.Ccoten from
(select * from @t where cid%3=1) n
join (select cid-1 cid,Ccoten from @t where cid%3=2) b on n.cid=b.cid
join (select cid-2 cid,Ccoten from @t where cid%3=0) x on n.cid=x.cid
2018年03月22日 07点03分 2
1