something likeSELECT ID,NextID,[Purch#],MAX(CASE WHEN Rn =1 THEN Sequence END) AS Sequence1,MAX(CASE WHEN Rn =1 THEN Type END) AS Type1,MAX(CASE WHEN Rn =1 THEN NameFull END) AS NameFull1,MAX(CASE WHEN Rn =2 THEN Sequence END) AS Sequence2,MAX(CASE WHEN Rn =2 THEN Type END) AS Type2,MAX(CASE WHEN Rn =2 THEN NameFull END) AS NameFull2,MAX(CASE WHEN Rn =3 THEN Sequence END) AS Sequence3,MAX(CASE WHEN Rn =3 THEN Type END) AS Type3,MAX(CASE WHEN Rn =3 THEN NameFull END) AS NameFull3FROM(SELECT ROW_NUMBER() OVER (PARTITION BY ID,NextID,[Purch#] ORDER BY Sequence) AS Rn,*FROM table)tGROUP BY ID,NextID,[Purch#]
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs