The cte + pivot way
DECLARE @sample TABLE( Col1 varchar(20), Col2 int)INSERT INTO @sampleSELECT 'Vista', 2005 UNION ALLSELECT 'Distinguish', 2005 UNION ALLSELECT 'ColonialVoice', 2006 UNION ALLSELECT 'Vista', 2006 UNION ALLSELECT 'Vista', 2007 UNION ALLSELECT 'SuperiorCard', 2007 UNION ALLSELECT 'Distinguish', 2007;WITH sample_data (RowNo, Col1, Col2)AS( SELECT RowNo = row_number() OVER (PARTITION BY Col2 ORDER BY Col1), Col1, Col2 FROM @sample)SELECT [2005], [2006], [2007]FROM sample_datapivot( MAX(Col1) FOR Col2 IN ([2005], [2006], [2007])) p/* RESULT :2005 2006 2007 -------------------- -------------------- -------------------- Distinguish ColonialVoice DistinguishVista Vista SuperiorCardNULL NULL Vista(3 row(s) affected)*/
KH[spoiler]Time is always against us[/spoiler]