Untitled
SELECT Matriz, Mes, Ano, Cstpis, Cstcofins, SUM(Vlrcontabil), SUM(Nvl(Basepiscalcqtde, Basepis)), Nvl(Aliqpiscalcqtde, Aliqpis), SUM(Vlrpis), SUM(Basecofins), Nvl(Aliqcofinscalcqtde, Aliqcofins), SUM(Vlrcofins), Indinternoexterno, Indcumulativo, Indtribut, Codnatrec, Codcontribapur , SUBSTR( TO_CHAR( B.CODITEM ) || ' - ' || B.DESCITEM , 0, 250 ) FROM Rfv_Debpiscofins_Nivel4 a, RFV_TABAUXPISCOFINS B WHERE a.MATRIZ = and a.ano = and a.MES = and CASE WHEN a.Codnatrec IS NOT NULL THEN a.Codnatrec ELSE a.Codcontribapur END = b.Coditem(+) AND CASE WHEN a.Codnatrec IS NOT NULL THEN Decode(a.Cstpis, '02', '4.3.10', '03', '4.3.11', '04', Decode(b.Codtabela(+), '4.3.10', '4.3.10', '4.3.11'), '05', '4.3.12', '06', '4.3.13', '07', '4.3.14', '08', '4.3.15', '09', '4.3.16')
Leave a Comment