Use the PIVOT operator. There is documentation here: http://technet.microsoft.com/en-us/library/ms177410(v=sql.100).aspxThe following is an example. When you ask a question, if you post the statements that create the table and populate the data (the first two lines in the code below) that makes it easier for someone to write the code against it.CREATE TABLE #test(test1 INT, test2 INT);INSERT INTO #test VALUES (1 ,34),(1 ,36),(2, 48),(3, 54),(3, 67),(3 ,69);WITH cte AS( SELECT *,ROW_NUMBER() OVER (PARTITION BY test1 ORDER BY test2 ) AS RN FROM #test)SELECT * FROMctePIVOT (MAX(test2) FOR RN IN ([1],[2],[3],[4]))PDROP TABLE #test;