Untitled

mail@pastecode.io avatar
unknown
sql
2 months ago
1.1 kB
10
Indexable
Never
--#21646
select     e.co_exportacao_importacao as "Lote",
        e.nu_contrato as "Contrato",
        e.nu_nota_fiscal as "Numero da Nota", 
        '41.05.001' as "Produto", 
        '0001' as "Item", 
        e.vl_percentual as "Percentual", 
        e.co_centro_custo as "Centro de Custo", 
        (case when e.tp_servico = 'A' then 'A000'
            when e.tp_servico = 'E' then 'E000'
            when e.tp_servico = 'C' then 'H000'
        end) as "Item Contabil", 
        (case when e.tp_servico = 'A' then '1111002'
            when e.tp_servico = 'E' then '1122001'
            when e.tp_servico = 'C' then '1221001'
        end) as "Classe de Valor", 
        e.vl_saldo_fatura as "Valor", 
        e.filial as "Filial Rateio", 
        ie.dt_acao as "Data Ação" 
from proenergia.tb_exportacao e
inner join proenergia.tb_importacao_exportacao ie on (e.co_exportacao_importacao = ie.co_seq_acao)
where e.tp_registro = 'C' and extract(month from ie.dt_acao) = 11 and extract(year from ie.dt_acao) = 2020 --Mes e Ano
order by e.co_exportacao_importacao, e.nu_contrato, e.nu_nota_fiscal, e.vl_percentual desc
Leave a Comment