Represent multiple rows of data in one column as multiple columns in one row SQL server
问题 I have a table with the following structure and data: batsman | runs | year 1 | 800 | 2012 1 | 950 | 2011 1 | 1050 | 2010 2 | 550 | 2012 2 | 650 | 2011 2 | 400 | 2010 3 | 900 | 2012 This data needs to be Selected through a sql query as: batsman | 2012 | 2011 | 2010 1 | 800 | 950 | 1050 2 | 550 | 650 | 400 3 | 900 | - | - I'm trying to do this through a stored proc. The assumption can be made that the number of columns (in terms of years) is fixed: 3. Also note, there are no arithmetic