0
I need to make this sales chart Join with the Nfe table, however the NFE table may have more than one result which causes change in total sales, how can I change this Join so that only take the last note?
select
sum(total_venda) as total_venda
from vendas v
LEFT OUTER JOIN nfe n ON (v.cod_venda = n.cod_venda and n.status like 'Emitida' and n.excluido is null)
I updated the answer according to your need.
– Lucas Brogni