set ansi_nulls on go set quoted_identifier on go create table [dbo].[yearsalary]( [year] [int] null, [salary] [money] null ) on [primary] go select * from yearsalary; select 'year' as workyear,[2011],[2012],[2013],[2014],[2015],[2016],[2017],[2018],[2019] from ( select year,salary from yearsalary) as sourcetable pivot ( avg(salary) for year in([2011],[2012],[2013],[2014],[2015],[2016],[2017],[2018],[2019]) ) as pivottable