SQLTeam.com | Weblogs | Forums

Valor final de cada Linha

Bom dia Pessoal,

Tenho uma query que não está totalizando a ultima coluna, gostaria se possível de uma ajuda de vocês.

Query:
WITH TMPESTONO (NOME_IMPOSTO ,MES,VALOR) AS
(
SELECT 'ESTORNO NORMAL MATRIZ'AS NOME_IMPOSTO, 'F_'+SZN.ZN_ITEM AS FILFOR, ((SZN.ZN_PRV*SZN.ZN_PRCAPL)/100) AS TOTAL
FROM
SZN010 SZN
WHERE
SZN.D_E_L_E_T_ = ' '
AND SZN.ZN_ITEM IN ('01','16','30','40','46','51','52','60','70','72','73','80')
AND SZN.ZN_DATA BETWEEN '20211101' AND '20211126'
AND SZN.ZN_DESC =('SALARIO')

) 

SELECT
*
FROM
(
SELECT
NOME_IMPOSTO,MES,VALOR
FROM
TMPESTONO
) AS
PivotData
PIVOT
(
SUM(VALOR)
FOR MES IN (
[F_16],[F_30],[F_40],[F_46],[F_51],[F_52],[F_60],[F_70],[F_72],[F_73],[TOTAL])
) AS
PivotTable2
ORDER BY 1

kinda hard to help without DDL and sample data