日期:2014-05-17 浏览次数:20580 次
if OBJECT_ID('tb')>0 drop table tb
go
create table tb(number int,name varchar(20))
insert tb
select top 100 rn1=ROW_NUMBER()over(order by getdate()),ROW_NUMBER()over(order by getdate())
from master..spt_values
;with t as
(
select rn1=(ROW_NUMBER()over(order by getdate())-1)%10+1,
rn2=(ROW_NUMBER()over(order by getdate())-1)/10+1,
*
from tb
)
select max(case when rn1=1 then number else '' end) number,
max(case when rn1=1 then name else '' end) name,
max(case when rn1=2 then number else '' end) number,
max(case when rn1=2 then name else '' end) name,
max(case when rn1=3 then number else '' end) number,
max(case when rn1=3 then name else '' end) name,
max(case when rn1=4 then number else '' end) number,
max(case when rn1=4 then name else '' end) name,