I already search for multiple pivots but still I haven't found similar to mine. I am using SQL Server 2008.
I already created a query with pivot:
select *
from
(select
branch, sum(balance) [balance],
year(docdate) [year], month(docdate) [month]
from
tempprt
group by
branch, year(docdate), month(docdate)) as a
pivot
(sum(balance)
for month in ([1], [2])) as pvt1
and I get this output:
Now, I want to sum the columns 1 and 2 per year and make the year as columns:
Your help is appreciated. Thank you!