select
'17' as "IDENTIFICADOR", --1	 
null as codigo,--2	
pviprocod as codProduto,--3	 
pvfvcodrem as codPedido,--4	 
pvidescflex as percentualDesconto,--5	 
null as percentualAcrescimo,--6	 
pvivltotal as valorTotalProdutosComDesconto,--7
pvivltab as valorUnitarioSemDesconto,--8
pvivlven as valorUnitarioComDesconto,--9
pviqtdeatecar as qtde,--10	 
null as idPedido,--11
pviinfadprod as observacao,--12
pvivlipi as valorTotalIPI,--13
pvivlst as valorTotal_ICMS_ST,--14
pvivltotal+pvivlipi+pvivlst as valorTotalComImpostos,--15
case when pviqtdeatecar > 0 then pvivltab+((pvivlipi/pviqtdeatecar)+(pvivlst/pviqtdeatecar)) else 0 end as valorUnitarioComImpostos,--16
(pvivltab - pvivlven) as valorTotalDescontoRateado,--17
(pvivltab*pviqtdeatecar) as valorProdutosSemRateioDesconto,--18
pvivlven as valorUnitarioSemRateioDesconto,--19
(pviqtdeatecar - pviqtde) as qtdeCancelado,--20
case when pvsta = 'FT' then pviqtdeatecar else 0 end as qtdeFaturado,--21
pvidescflex as valorFlexMovimentado,--22
(pvivltab*pviqtdeatecar) as valorTotalProdutosSemPercCondPag,--23
null as numOpcaoPrecoPreFixado,--24	
pvicadhorario as dataHoraCadastro,--25
null as percComissao,--26
null as valorTotalComissao,--27
null as qtdeEmbalagem,--28
null as usouTabelaDesconto,--29
null as valorUnitarioListaPreco,--30	 
null as valorTaxaAdicional,--31
null as valorAbaterBCComissao,--32
null as percComissaoBonificada,--33
null as pesoBruto,--34
null as pesoLiquido,--35
null as cubagem,--36
pvivlfrete as valorFrete,--37
null as freteSugerido,--38	 
null as percMargemContribuicao,--39	 
null as custoReposicaoNaVenda,--40	 
null as valorUnitarioSemDescontoSobreDesconto,--41	 
null as percDescontoDigitado--42	 
from pvi
join pv on pvipvcod = pvcod
where pvfvcodrem is not null
and pvcadhorario between now()-interval '7 Days' and now()
ExecutarScriptSempre
