 <pre><code>create table #txn ( year smallint, Jan money, Feb money, Mar money, Apr money, May money, Jun money, Jul money, Aug money, Sep money, Oct money, Nov money, Dec money ) insert #txn values(2014,null,null,null,null,null,null,null,null,null,95,36.89,95), (2015,100,6389.27,null,null,1035,257,669.05,0,null,514,2791.01,null) select year, month, money from #txn unpivot ( money for month in (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec) ) unpivotalias ;with aggregate as ( select year, sum(money) as 'YTD', sum(money)/count(*) as 'AVG' from #txn unpivot ( money for month in (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec) ) unpivotalias group by year ) select t.year,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,YTD,AVG from #txn as t join aggregate as a on t.year = a.year order by t.year </code></pre>