日期:2014-05-16 浏览次数:20468 次
select
max(case when (id-1)%4=0 then name else '' end) ,
max(case when (id-1)%4=0 then pass else '' end) ,
max(case when (id-1)%4=1 then name else '' end) ,
max(case when (id-1)%4=1 then pass else '' end) ,
max(case when (id-1)%4=2 then name else '' end) ,
max(case when (id-1)%4=2 then pass else '' end) ,
max(case when (id-1)%4=3 then name else '' end) ,
max(case when (id-1)%4=3 then pass else '' end)
from
(select id=row_number()over(order by getdate()),* from tb) as t
--drop table t
create table t(name varchar(10),pass varchar(10))
insert into t
select 'a', 'a' union all
select 'b', 'b' union all
select 'c', 'c' union all
select 'd', 'd' union all
select 'e', 'e' union all
select 'f', 'f' union all