sqlserver将数据分隔成两大列

select  a.[ITTECHID] AS ITRECID1,b.[ITTECHID] AS ITRECID2,a.HANDLETIME AS HANDLETIME1,b.HANDLETIME AS HANDLETIME2

from(

select *from(select [ITTECHID],HANDLETIME,row_number()over(order by getdate()) as row from [PSNITTECH] WHERE [PERSONID]  = N'16fc6370-b0b1-4ff3-ac38-e965370ea003' ) m where m.row %2=1) a

left join (

select *from(select [ITTECHID],HANDLETIME,row_number()over(order by getdate()) as row from [PSNITTECH] WHERE [PERSONID]  = N'16fc6370-b0b1-4ff3-ac38-e965370ea003' ) m where m.row %2=0) b

on a.row+1=b.row

posted @ 2015-08-07 14:06  zhuyu528  阅读(162)  评论(0编辑  收藏  举报