Fiscal

Consulta de SQL para o SUFRAMA

FISCAL.FAQ-10850
select a + b, 'update itens_doc_entradas_saidas set valor_desconto_item = ' || (a+b) || ' where id = ' || id || ';' from (
select id, sequencia, valor_desconto_item,
(select valor_tributo from operacoes_fiscais_itens_documento o where tributo_id = (select id from tributos where sigla ='SUFRAMA01' ) and item_documento_id = BASE.ID) as a,
(select valor_tributo from operacoes_fiscais_itens_documento o where tributo_id = (select id from tributos where sigla ='SUFRAMA02' ) and item_documento_id = BASE.ID) as b
from itens_doc_entradas_saidas BASE where documento_id = 1281808) query;