Quantcast
Channel: SQLServerCentral » SQL Server 2012 » SQL Server 2012 - T-SQL » Latest topics
Viewing all articles
Browse latest Browse all 4901

Pivot with sum of multiple columns

$
0
0
I have a table with product sales by region for three years - 2010-2012tbl1prod region year revenuep1 r1 2010 100p1 r1 2010 15p1 r2 2011 150p1 r3 2012 50p2 r1 2010 200p2 r2 2012 25p3 r1 2011 300p3 r1 2012 400p3 r4 2012 50I need to show the above data as below - with year as columnsprod region 2010 2011 2012p1 r1 115 0 0p1 r2 0 150 0p1 r3 0 0 50p2 r1 200 0 0and so on..I know how to pivot on sum of one column but modifying that for multiple columns give error.Can anyone please help? Is there any other I can do this?Thanks

Viewing all articles
Browse latest Browse all 4901

Trending Articles