row convert to column in sql 2008
问题 I want to convert a series of rows into a series of columns create table #cusphone(cusid int,cusph1 int) insert into #cusphone values(1,48509) insert into #cusphone values(1,48508) insert into #cusphone values(1,48507) insert into #cusphone values(2,48100) so that the output is like this 1 48509 48508 48507 2 48100 null null 回答1: You can use the same approach of rank() and then use the new PIVOT function as follows: with cusCte as( select cusid,cusph1,RANK() over (partition by cusid order by