日期:2014-05-17 浏览次数:20411 次
declare @tb table([col] varchar(3))
insert @tb
select '001' union all
select '002' union all
select '003' union all
select '004' union all
select '005' union all
select '006' union all
select '007' union all
select '008''
;WITH TEMP AS
(
SELECT *,ROW_NUMBER() OVER(ORDER BY getdate()) AS RID
FROM @tb
)
SELECT
col1=max(case when RID%3=1 then col end),
col2=max(case when RID%3=2 then col end),
col3=max(case when RID%3=0 then col end)
FROM TEMP
GROUP BY (RID-1)/3