Is it possible to make one row of TOTALS per column? The explanation of the totals per line was fantastic and it turned out beautiful in my project. Thank you.
My code:
SELECT
ano AS Ano,
CCUSTOS AS [Centro custos],
coalesce([1], 0) janeiro,
coalesce([2], 0) fevereiro,
coalesce([3], 0) março,
coalesce([4], 0) abril,
coalesce([5], 0) maio,
coalesce([6], 0) junho,
coalesce([7], 0) julho,
coalesce([8], 0) agosto,
coalesce([9], 0) setembro,
coalesce([10], 0) outubro,
coalesce([11], 0) novembro,
coalesce([12], 0) dezembro,
coalesce([1],0)+ coalesce([2],0)+ coalesce([3],0)+ coalesce([4],0)+ coalesce([5],0)+ coalesce([6],0)+ coalesce([7],0)+ coalesce([8],0)+ coalesce([9],0)+ coalesce([10],0)+ coalesce([11],0)+ coalesce([12],0) AS Total
FROM V_despesas_group_CC
PIVOT (SUM(total_valor) FOR MES IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]))P
ORDER BY CCUSTOS